diff --git a/examples/data-sources/netbox_json_dcim_inventory_item_roles_list/data-source.tf b/examples/data-sources/netbox_json_dcim_inventory_item_roles_list/data-source.tf new file mode 100644 index 000000000..7af602099 --- /dev/null +++ b/examples/data-sources/netbox_json_dcim_inventory_item_roles_list/data-source.tf @@ -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) +} diff --git a/examples/data-sources/netbox_json_dcim_inventory_item_templates_list/data-source.tf b/examples/data-sources/netbox_json_dcim_inventory_item_templates_list/data-source.tf new file mode 100644 index 000000000..c84125eb6 --- /dev/null +++ b/examples/data-sources/netbox_json_dcim_inventory_item_templates_list/data-source.tf @@ -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) +} diff --git a/examples/data-sources/netbox_json_dcim_module_bay_templates_list/data-source.tf b/examples/data-sources/netbox_json_dcim_module_bay_templates_list/data-source.tf new file mode 100644 index 000000000..60857de83 --- /dev/null +++ b/examples/data-sources/netbox_json_dcim_module_bay_templates_list/data-source.tf @@ -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) +} diff --git a/examples/data-sources/netbox_json_dcim_module_bays_list/data-source.tf b/examples/data-sources/netbox_json_dcim_module_bays_list/data-source.tf new file mode 100644 index 000000000..9a5591ede --- /dev/null +++ b/examples/data-sources/netbox_json_dcim_module_bays_list/data-source.tf @@ -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) +} diff --git a/examples/data-sources/netbox_json_dcim_module_types_list/data-source.tf b/examples/data-sources/netbox_json_dcim_module_types_list/data-source.tf new file mode 100644 index 000000000..3325b0210 --- /dev/null +++ b/examples/data-sources/netbox_json_dcim_module_types_list/data-source.tf @@ -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) +} diff --git a/examples/data-sources/netbox_json_dcim_modules_list/data-source.tf b/examples/data-sources/netbox_json_dcim_modules_list/data-source.tf new file mode 100644 index 000000000..7e778dbbb --- /dev/null +++ b/examples/data-sources/netbox_json_dcim_modules_list/data-source.tf @@ -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) +} diff --git a/examples/data-sources/netbox_json_ipam_service_templates_list/data-source.tf b/examples/data-sources/netbox_json_ipam_service_templates_list/data-source.tf new file mode 100644 index 000000000..4ac6169b4 --- /dev/null +++ b/examples/data-sources/netbox_json_ipam_service_templates_list/data-source.tf @@ -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) +} diff --git a/netbox/data_netbox_json_dcim_inventory_item_roles_list.go b/netbox/data_netbox_json_dcim_inventory_item_roles_list.go new file mode 100644 index 000000000..353ded35f --- /dev/null +++ b/netbox/data_netbox_json_dcim_inventory_item_roles_list.go @@ -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 +} diff --git a/netbox/data_netbox_json_dcim_inventory_item_templates_list.go b/netbox/data_netbox_json_dcim_inventory_item_templates_list.go new file mode 100644 index 000000000..8ca0495ca --- /dev/null +++ b/netbox/data_netbox_json_dcim_inventory_item_templates_list.go @@ -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 +} diff --git a/netbox/data_netbox_json_dcim_module_bay_templates_list.go b/netbox/data_netbox_json_dcim_module_bay_templates_list.go new file mode 100644 index 000000000..5219db6b1 --- /dev/null +++ b/netbox/data_netbox_json_dcim_module_bay_templates_list.go @@ -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 +} diff --git a/netbox/data_netbox_json_dcim_module_bays_list.go b/netbox/data_netbox_json_dcim_module_bays_list.go new file mode 100644 index 000000000..c21f9870d --- /dev/null +++ b/netbox/data_netbox_json_dcim_module_bays_list.go @@ -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 +} diff --git a/netbox/data_netbox_json_dcim_module_types_list.go b/netbox/data_netbox_json_dcim_module_types_list.go new file mode 100644 index 000000000..3bc0c55bf --- /dev/null +++ b/netbox/data_netbox_json_dcim_module_types_list.go @@ -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 +} diff --git a/netbox/data_netbox_json_dcim_modules_list.go b/netbox/data_netbox_json_dcim_modules_list.go new file mode 100644 index 000000000..37b1b40d2 --- /dev/null +++ b/netbox/data_netbox_json_dcim_modules_list.go @@ -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 +} diff --git a/netbox/data_netbox_json_ipam_service_templates_list.go b/netbox/data_netbox_json_ipam_service_templates_list.go new file mode 100644 index 000000000..0c6cd649b --- /dev/null +++ b/netbox/data_netbox_json_ipam_service_templates_list.go @@ -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/ipam" +) + +func dataNetboxJSONIpamServiceTemplatesList() *schema.Resource { + return &schema.Resource{ + Description: "Get json output from the ipam_service_templates_list Netbox endpoint.", + Read: dataNetboxJSONIpamServiceTemplatesListRead, + + 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 dataNetboxJSONIpamServiceTemplatesListRead(d *schema.ResourceData, m interface{}) error { + client := m.(*netboxclient.NetBoxAPI) + + params := ipam.NewIpamServiceTemplatesListParams() + limit := int64(d.Get("limit").(int)) + params.Limit = &limit + + list, err := client.Ipam.IpamServiceTemplatesList(params, nil) + if err != nil { + return err + } + + j, _ := json.Marshal(list.Payload.Results) + + d.Set("json", string(j)) + d.SetId("NetboxJSONIpamServiceTemplatesList") + + return nil +} diff --git a/netbox/provider.go b/netbox/provider.go index 581bafa1a..7f7201744 100644 --- a/netbox/provider.go +++ b/netbox/provider.go @@ -69,9 +69,15 @@ func Provider() *schema.Provider { "netbox_json_dcim_front_port_templates_list": dataNetboxJSONDcimFrontPortTemplatesList(), "netbox_json_dcim_interfaces_list": dataNetboxJSONDcimInterfacesList(), "netbox_json_dcim_interface_templates_list": dataNetboxJSONDcimInterfaceTemplatesList(), + "netbox_json_dcim_inventory_item_roles_list": dataNetboxJSONDcimInventoryItemRolesList(), "netbox_json_dcim_inventory_items_list": dataNetboxJSONDcimInventoryItemsList(), + "netbox_json_dcim_inventory_item_templates_list": dataNetboxJSONDcimInventoryItemTemplatesList(), "netbox_json_dcim_locations_list": dataNetboxJSONDcimLocationsList(), "netbox_json_dcim_manufacturers_list": dataNetboxJSONDcimManufacturersList(), + "netbox_json_dcim_module_bays_list": dataNetboxJSONDcimModuleBaysList(), + "netbox_json_dcim_module_bay_templates_list": dataNetboxJSONDcimModuleBayTemplatesList(), + "netbox_json_dcim_modules_list": dataNetboxJSONDcimModulesList(), + "netbox_json_dcim_module_types_list": dataNetboxJSONDcimModuleTypesList(), "netbox_json_dcim_platforms_list": dataNetboxJSONDcimPlatformsList(), "netbox_json_dcim_power_feeds_list": dataNetboxJSONDcimPowerFeedsList(), "netbox_json_dcim_power_outlets_list": dataNetboxJSONDcimPowerOutletsList(), @@ -110,6 +116,7 @@ func Provider() *schema.Provider { "netbox_json_ipam_roles_list": dataNetboxJSONIpamRolesList(), "netbox_json_ipam_route_targets_list": dataNetboxJSONIpamRouteTargetsList(), "netbox_json_ipam_services_list": dataNetboxJSONIpamServicesList(), + "netbox_json_ipam_service_templates_list": dataNetboxJSONIpamServiceTemplatesList(), "netbox_json_ipam_vlan_groups_list": dataNetboxJSONIpamVlanGroupsList(), "netbox_json_ipam_vlans_list": dataNetboxJSONIpamVlansList(), "netbox_json_ipam_vrfs_list": dataNetboxJSONIpamVrfsList(), diff --git a/utils/generateJsonDatasources b/utils/generateJsonDatasources index 929110b68..caeb93bfc 100755 --- a/utils/generateJsonDatasources +++ b/utils/generateJsonDatasources @@ -84,52 +84,52 @@ cat << EOF > ${SCRIPT_PATH}/../netbox/data_netbox_json_${ENDPOINT}_list.go package netbox import ( - "encoding/json" + "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/${SECTION,}" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + netboxclient "github.com/smutel/go-netbox/netbox/client" + "github.com/smutel/go-netbox/netbox/client/${SECTION,}" ) func dataNetboxJSON${SECTION}${ITEM}List() *schema.Resource { - return &schema.Resource{ - Description: "Get json output from the ${ENDPOINT}_list Netbox endpoint.", - Read: dataNetboxJSON${SECTION}${ITEM}ListRead, - - 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.", - }, - }, - } + return &schema.Resource{ + Description: "Get json output from the ${ENDPOINT}_list Netbox endpoint.", + Read: dataNetboxJSON${SECTION}${ITEM}ListRead, + + 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 dataNetboxJSON${SECTION}${ITEM}ListRead(d *schema.ResourceData, m interface{}) error { - client := m.(*netboxclient.NetBoxAPI) + client := m.(*netboxclient.NetBoxAPI) - params := ${SECTION,}.New${SECTION}${ITEM}ListParams() - limit := int64(d.Get("limit").(int)) - params.Limit = &limit + params := ${SECTION,}.New${SECTION}${ITEM}ListParams() + limit := int64(d.Get("limit").(int)) + params.Limit = &limit - list, err := client.${SECTION}.${SECTION}${ITEM}List(params, nil) - if err != nil { - return err - } + list, err := client.${SECTION}.${SECTION}${ITEM}List(params, nil) + if err != nil { + return err + } - j, _ := json.Marshal(list.Payload.Results) + j, _ := json.Marshal(list.Payload.Results) - d.Set("json", string(j)) - d.SetId("NetboxJSON${SECTION}${ITEM}List") + d.Set("json", string(j)) + d.SetId("NetboxJSON${SECTION}${ITEM}List") - return nil + return nil } EOF