-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh: Update JSON data/resource with Netbox 3.2
- Loading branch information
Showing
16 changed files
with
440 additions
and
34 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
examples/data-sources/netbox_json_dcim_inventory_item_roles_list/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "netbox_json_dcim_inventory_item_roles_list" "test" { | ||
limit = 0 | ||
} | ||
|
||
output "example" { | ||
value = jsondecode(data.netbox_json_dcim_inventory_item_roles_list.test.json) | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/data-sources/netbox_json_dcim_inventory_item_templates_list/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "netbox_json_dcim_inventory_item_templates_list" "test" { | ||
limit = 0 | ||
} | ||
|
||
output "example" { | ||
value = jsondecode(data.netbox_json_dcim_inventory_item_templates_list.test.json) | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/data-sources/netbox_json_dcim_module_bay_templates_list/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "netbox_json_dcim_module_bay_templates_list" "test" { | ||
limit = 0 | ||
} | ||
|
||
output "example" { | ||
value = jsondecode(data.netbox_json_dcim_module_bay_templates_list.test.json) | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/data-sources/netbox_json_dcim_module_bays_list/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "netbox_json_dcim_module_bays_list" "test" { | ||
limit = 0 | ||
} | ||
|
||
output "example" { | ||
value = jsondecode(data.netbox_json_dcim_module_bays_list.test.json) | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/data-sources/netbox_json_dcim_module_types_list/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "netbox_json_dcim_module_types_list" "test" { | ||
limit = 0 | ||
} | ||
|
||
output "example" { | ||
value = jsondecode(data.netbox_json_dcim_module_types_list.test.json) | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/data-sources/netbox_json_dcim_modules_list/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "netbox_json_dcim_modules_list" "test" { | ||
limit = 0 | ||
} | ||
|
||
output "example" { | ||
value = jsondecode(data.netbox_json_dcim_modules_list.test.json) | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/data-sources/netbox_json_ipam_service_templates_list/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "netbox_json_ipam_service_templates_list" "test" { | ||
limit = 0 | ||
} | ||
|
||
output "example" { | ||
value = jsondecode(data.netbox_json_ipam_service_templates_list.test.json) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package netbox | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
netboxclient "github.com/smutel/go-netbox/netbox/client" | ||
"github.com/smutel/go-netbox/netbox/client/dcim" | ||
) | ||
|
||
func dataNetboxJSONDcimInventoryItemRolesList() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Get json output from the dcim_inventory_item_roles_list Netbox endpoint.", | ||
Read: dataNetboxJSONDcimInventoryItemRolesListRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"limit": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 0, | ||
Description: "The max number of returned results. If 0 is specified, all records will be returned.", | ||
}, | ||
"json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "JSON output of the list of objects for this Netbox endpoint.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataNetboxJSONDcimInventoryItemRolesListRead(d *schema.ResourceData, m interface{}) error { | ||
client := m.(*netboxclient.NetBoxAPI) | ||
|
||
params := dcim.NewDcimInventoryItemRolesListParams() | ||
limit := int64(d.Get("limit").(int)) | ||
params.Limit = &limit | ||
|
||
list, err := client.Dcim.DcimInventoryItemRolesList(params, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
j, _ := json.Marshal(list.Payload.Results) | ||
|
||
d.Set("json", string(j)) | ||
d.SetId("NetboxJSONDcimInventoryItemRolesList") | ||
|
||
return nil | ||
} |
50 changes: 50 additions & 0 deletions
50
netbox/data_netbox_json_dcim_inventory_item_templates_list.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package netbox | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
netboxclient "github.com/smutel/go-netbox/netbox/client" | ||
"github.com/smutel/go-netbox/netbox/client/dcim" | ||
) | ||
|
||
func dataNetboxJSONDcimInventoryItemTemplatesList() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Get json output from the dcim_inventory_item_templates_list Netbox endpoint.", | ||
Read: dataNetboxJSONDcimInventoryItemTemplatesListRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"limit": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 0, | ||
Description: "The max number of returned results. If 0 is specified, all records will be returned.", | ||
}, | ||
"json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "JSON output of the list of objects for this Netbox endpoint.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataNetboxJSONDcimInventoryItemTemplatesListRead(d *schema.ResourceData, m interface{}) error { | ||
client := m.(*netboxclient.NetBoxAPI) | ||
|
||
params := dcim.NewDcimInventoryItemTemplatesListParams() | ||
limit := int64(d.Get("limit").(int)) | ||
params.Limit = &limit | ||
|
||
list, err := client.Dcim.DcimInventoryItemTemplatesList(params, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
j, _ := json.Marshal(list.Payload.Results) | ||
|
||
d.Set("json", string(j)) | ||
d.SetId("NetboxJSONDcimInventoryItemTemplatesList") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package netbox | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
netboxclient "github.com/smutel/go-netbox/netbox/client" | ||
"github.com/smutel/go-netbox/netbox/client/dcim" | ||
) | ||
|
||
func dataNetboxJSONDcimModuleBayTemplatesList() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Get json output from the dcim_module_bay_templates_list Netbox endpoint.", | ||
Read: dataNetboxJSONDcimModuleBayTemplatesListRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"limit": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 0, | ||
Description: "The max number of returned results. If 0 is specified, all records will be returned.", | ||
}, | ||
"json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "JSON output of the list of objects for this Netbox endpoint.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataNetboxJSONDcimModuleBayTemplatesListRead(d *schema.ResourceData, m interface{}) error { | ||
client := m.(*netboxclient.NetBoxAPI) | ||
|
||
params := dcim.NewDcimModuleBayTemplatesListParams() | ||
limit := int64(d.Get("limit").(int)) | ||
params.Limit = &limit | ||
|
||
list, err := client.Dcim.DcimModuleBayTemplatesList(params, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
j, _ := json.Marshal(list.Payload.Results) | ||
|
||
d.Set("json", string(j)) | ||
d.SetId("NetboxJSONDcimModuleBayTemplatesList") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package netbox | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
netboxclient "github.com/smutel/go-netbox/netbox/client" | ||
"github.com/smutel/go-netbox/netbox/client/dcim" | ||
) | ||
|
||
func dataNetboxJSONDcimModuleBaysList() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Get json output from the dcim_module_bays_list Netbox endpoint.", | ||
Read: dataNetboxJSONDcimModuleBaysListRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"limit": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 0, | ||
Description: "The max number of returned results. If 0 is specified, all records will be returned.", | ||
}, | ||
"json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "JSON output of the list of objects for this Netbox endpoint.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataNetboxJSONDcimModuleBaysListRead(d *schema.ResourceData, m interface{}) error { | ||
client := m.(*netboxclient.NetBoxAPI) | ||
|
||
params := dcim.NewDcimModuleBaysListParams() | ||
limit := int64(d.Get("limit").(int)) | ||
params.Limit = &limit | ||
|
||
list, err := client.Dcim.DcimModuleBaysList(params, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
j, _ := json.Marshal(list.Payload.Results) | ||
|
||
d.Set("json", string(j)) | ||
d.SetId("NetboxJSONDcimModuleBaysList") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package netbox | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
netboxclient "github.com/smutel/go-netbox/netbox/client" | ||
"github.com/smutel/go-netbox/netbox/client/dcim" | ||
) | ||
|
||
func dataNetboxJSONDcimModuleTypesList() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Get json output from the dcim_module_types_list Netbox endpoint.", | ||
Read: dataNetboxJSONDcimModuleTypesListRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"limit": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 0, | ||
Description: "The max number of returned results. If 0 is specified, all records will be returned.", | ||
}, | ||
"json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "JSON output of the list of objects for this Netbox endpoint.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataNetboxJSONDcimModuleTypesListRead(d *schema.ResourceData, m interface{}) error { | ||
client := m.(*netboxclient.NetBoxAPI) | ||
|
||
params := dcim.NewDcimModuleTypesListParams() | ||
limit := int64(d.Get("limit").(int)) | ||
params.Limit = &limit | ||
|
||
list, err := client.Dcim.DcimModuleTypesList(params, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
j, _ := json.Marshal(list.Payload.Results) | ||
|
||
d.Set("json", string(j)) | ||
d.SetId("NetboxJSONDcimModuleTypesList") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package netbox | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
netboxclient "github.com/smutel/go-netbox/netbox/client" | ||
"github.com/smutel/go-netbox/netbox/client/dcim" | ||
) | ||
|
||
func dataNetboxJSONDcimModulesList() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Get json output from the dcim_modules_list Netbox endpoint.", | ||
Read: dataNetboxJSONDcimModulesListRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"limit": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 0, | ||
Description: "The max number of returned results. If 0 is specified, all records will be returned.", | ||
}, | ||
"json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "JSON output of the list of objects for this Netbox endpoint.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataNetboxJSONDcimModulesListRead(d *schema.ResourceData, m interface{}) error { | ||
client := m.(*netboxclient.NetBoxAPI) | ||
|
||
params := dcim.NewDcimModulesListParams() | ||
limit := int64(d.Get("limit").(int)) | ||
params.Limit = &limit | ||
|
||
list, err := client.Dcim.DcimModulesList(params, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
j, _ := json.Marshal(list.Payload.Results) | ||
|
||
d.Set("json", string(j)) | ||
d.SetId("NetboxJSONDcimModulesList") | ||
|
||
return nil | ||
} |
Oops, something went wrong.