diff --git a/netbox/data_netbox_json_circuits_circuit_terminations_list.go b/netbox/data_netbox_json_circuits_circuit_terminations_list.go index 29c866d4d..2894ec735 100644 --- a/netbox/data_netbox_json_circuits_circuit_terminations_list.go +++ b/netbox/data_netbox_json_circuits_circuit_terminations_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONCircuitsCircuitTerminationsListRead(d *schema.ResourceData, m return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Circuits.CircuitsCircuitTerminationsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONCircuitsCircuitTerminationsList") diff --git a/netbox/data_netbox_json_circuits_circuit_types_list.go b/netbox/data_netbox_json_circuits_circuit_types_list.go index b30368f73..7bea6fb01 100644 --- a/netbox/data_netbox_json_circuits_circuit_types_list.go +++ b/netbox/data_netbox_json_circuits_circuit_types_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONCircuitsCircuitTypesListRead(d *schema.ResourceData, m interf return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Circuits.CircuitsCircuitTypesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONCircuitsCircuitTypesList") diff --git a/netbox/data_netbox_json_circuits_circuits_list.go b/netbox/data_netbox_json_circuits_circuits_list.go index 17221113a..36bb1a23d 100644 --- a/netbox/data_netbox_json_circuits_circuits_list.go +++ b/netbox/data_netbox_json_circuits_circuits_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONCircuitsCircuitsListRead(d *schema.ResourceData, m interface{ return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Circuits.CircuitsCircuitsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONCircuitsCircuitsList") diff --git a/netbox/data_netbox_json_circuits_provider_networks_list.go b/netbox/data_netbox_json_circuits_provider_networks_list.go index 2e7bcc261..845f8f819 100644 --- a/netbox/data_netbox_json_circuits_provider_networks_list.go +++ b/netbox/data_netbox_json_circuits_provider_networks_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONCircuitsProviderNetworksListRead(d *schema.ResourceData, m in return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Circuits.CircuitsProviderNetworksList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONCircuitsProviderNetworksList") diff --git a/netbox/data_netbox_json_circuits_providers_list.go b/netbox/data_netbox_json_circuits_providers_list.go index ab1a58fc2..6fe773b85 100644 --- a/netbox/data_netbox_json_circuits_providers_list.go +++ b/netbox/data_netbox_json_circuits_providers_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONCircuitsProvidersListRead(d *schema.ResourceData, m interface return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Circuits.CircuitsProvidersList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONCircuitsProvidersList") diff --git a/netbox/data_netbox_json_dcim_cables_list.go b/netbox/data_netbox_json_dcim_cables_list.go index 0375b7bcc..0f263fc8e 100644 --- a/netbox/data_netbox_json_dcim_cables_list.go +++ b/netbox/data_netbox_json_dcim_cables_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimCablesListRead(d *schema.ResourceData, m interface{}) err return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimCablesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimCablesList") diff --git a/netbox/data_netbox_json_dcim_console_port_templates_list.go b/netbox/data_netbox_json_dcim_console_port_templates_list.go index 367af3765..9f4a422fb 100644 --- a/netbox/data_netbox_json_dcim_console_port_templates_list.go +++ b/netbox/data_netbox_json_dcim_console_port_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimConsolePortTemplatesListRead(d *schema.ResourceData, m in return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimConsolePortTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimConsolePortTemplatesList") diff --git a/netbox/data_netbox_json_dcim_console_ports_list.go b/netbox/data_netbox_json_dcim_console_ports_list.go index 202339d51..0400f5cc1 100644 --- a/netbox/data_netbox_json_dcim_console_ports_list.go +++ b/netbox/data_netbox_json_dcim_console_ports_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimConsolePortsListRead(d *schema.ResourceData, m interface{ return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimConsolePortsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimConsolePortsList") diff --git a/netbox/data_netbox_json_dcim_console_server_port_templates_list.go b/netbox/data_netbox_json_dcim_console_server_port_templates_list.go index 5f984c53f..8d7c6886e 100644 --- a/netbox/data_netbox_json_dcim_console_server_port_templates_list.go +++ b/netbox/data_netbox_json_dcim_console_server_port_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimConsoleServerPortTemplatesListRead(d *schema.ResourceData return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimConsoleServerPortTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimConsoleServerPortTemplatesList") diff --git a/netbox/data_netbox_json_dcim_console_server_ports_list.go b/netbox/data_netbox_json_dcim_console_server_ports_list.go index d78b353e7..7bf46f6e3 100644 --- a/netbox/data_netbox_json_dcim_console_server_ports_list.go +++ b/netbox/data_netbox_json_dcim_console_server_ports_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimConsoleServerPortsListRead(d *schema.ResourceData, m inte return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimConsoleServerPortsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimConsoleServerPortsList") diff --git a/netbox/data_netbox_json_dcim_device_bay_templates_list.go b/netbox/data_netbox_json_dcim_device_bay_templates_list.go index d8cf1ac77..8e2b0e225 100644 --- a/netbox/data_netbox_json_dcim_device_bay_templates_list.go +++ b/netbox/data_netbox_json_dcim_device_bay_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimDeviceBayTemplatesListRead(d *schema.ResourceData, m inte return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimDeviceBayTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimDeviceBayTemplatesList") diff --git a/netbox/data_netbox_json_dcim_device_bays_list.go b/netbox/data_netbox_json_dcim_device_bays_list.go index 297f757f6..280423e82 100644 --- a/netbox/data_netbox_json_dcim_device_bays_list.go +++ b/netbox/data_netbox_json_dcim_device_bays_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimDeviceBaysListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimDeviceBaysList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimDeviceBaysList") diff --git a/netbox/data_netbox_json_dcim_device_roles_list.go b/netbox/data_netbox_json_dcim_device_roles_list.go index e4e8d012c..70bf47f62 100644 --- a/netbox/data_netbox_json_dcim_device_roles_list.go +++ b/netbox/data_netbox_json_dcim_device_roles_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimDeviceRolesListRead(d *schema.ResourceData, m interface{} return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimDeviceRolesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimDeviceRolesList") diff --git a/netbox/data_netbox_json_dcim_device_types_list.go b/netbox/data_netbox_json_dcim_device_types_list.go index ceeb6b28b..dfe2e9ea4 100644 --- a/netbox/data_netbox_json_dcim_device_types_list.go +++ b/netbox/data_netbox_json_dcim_device_types_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimDeviceTypesListRead(d *schema.ResourceData, m interface{} return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimDeviceTypesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimDeviceTypesList") diff --git a/netbox/data_netbox_json_dcim_devices_list.go b/netbox/data_netbox_json_dcim_devices_list.go index 6d934ab97..ce69c4c4f 100644 --- a/netbox/data_netbox_json_dcim_devices_list.go +++ b/netbox/data_netbox_json_dcim_devices_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimDevicesListRead(d *schema.ResourceData, m interface{}) er return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimDevicesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimDevicesList") diff --git a/netbox/data_netbox_json_dcim_front_port_templates_list.go b/netbox/data_netbox_json_dcim_front_port_templates_list.go index d0ff16752..782e29d81 100644 --- a/netbox/data_netbox_json_dcim_front_port_templates_list.go +++ b/netbox/data_netbox_json_dcim_front_port_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimFrontPortTemplatesListRead(d *schema.ResourceData, m inte return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimFrontPortTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimFrontPortTemplatesList") diff --git a/netbox/data_netbox_json_dcim_front_ports_list.go b/netbox/data_netbox_json_dcim_front_ports_list.go index 3a3dda6e9..8e83526c7 100644 --- a/netbox/data_netbox_json_dcim_front_ports_list.go +++ b/netbox/data_netbox_json_dcim_front_ports_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimFrontPortsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimFrontPortsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimFrontPortsList") diff --git a/netbox/data_netbox_json_dcim_interface_templates_list.go b/netbox/data_netbox_json_dcim_interface_templates_list.go index 17184f334..f5ce183bf 100644 --- a/netbox/data_netbox_json_dcim_interface_templates_list.go +++ b/netbox/data_netbox_json_dcim_interface_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimInterfaceTemplatesListRead(d *schema.ResourceData, m inte return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimInterfaceTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimInterfaceTemplatesList") diff --git a/netbox/data_netbox_json_dcim_interfaces_list.go b/netbox/data_netbox_json_dcim_interfaces_list.go index 9a530dd9e..6bad97936 100644 --- a/netbox/data_netbox_json_dcim_interfaces_list.go +++ b/netbox/data_netbox_json_dcim_interfaces_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimInterfacesListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimInterfacesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimInterfacesList") diff --git a/netbox/data_netbox_json_dcim_inventory_item_roles_list.go b/netbox/data_netbox_json_dcim_inventory_item_roles_list.go index 353ded35f..fde055654 100644 --- a/netbox/data_netbox_json_dcim_inventory_item_roles_list.go +++ b/netbox/data_netbox_json_dcim_inventory_item_roles_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimInventoryItemRolesListRead(d *schema.ResourceData, m inte return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimInventoryItemRolesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimInventoryItemRolesList") diff --git a/netbox/data_netbox_json_dcim_inventory_item_templates_list.go b/netbox/data_netbox_json_dcim_inventory_item_templates_list.go index 8ca0495ca..c804f63c5 100644 --- a/netbox/data_netbox_json_dcim_inventory_item_templates_list.go +++ b/netbox/data_netbox_json_dcim_inventory_item_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimInventoryItemTemplatesListRead(d *schema.ResourceData, m return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimInventoryItemTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimInventoryItemTemplatesList") diff --git a/netbox/data_netbox_json_dcim_inventory_items_list.go b/netbox/data_netbox_json_dcim_inventory_items_list.go index c5580116c..1a7b896e6 100644 --- a/netbox/data_netbox_json_dcim_inventory_items_list.go +++ b/netbox/data_netbox_json_dcim_inventory_items_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimInventoryItemsListRead(d *schema.ResourceData, m interfac return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimInventoryItemsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimInventoryItemsList") diff --git a/netbox/data_netbox_json_dcim_locations_list.go b/netbox/data_netbox_json_dcim_locations_list.go index 64532305e..525e68a19 100644 --- a/netbox/data_netbox_json_dcim_locations_list.go +++ b/netbox/data_netbox_json_dcim_locations_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimLocationsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimLocationsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimLocationsList") diff --git a/netbox/data_netbox_json_dcim_manufacturers_list.go b/netbox/data_netbox_json_dcim_manufacturers_list.go index 5a646e0df..a4761b8c5 100644 --- a/netbox/data_netbox_json_dcim_manufacturers_list.go +++ b/netbox/data_netbox_json_dcim_manufacturers_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimManufacturersListRead(d *schema.ResourceData, m interface return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimManufacturersList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimManufacturersList") diff --git a/netbox/data_netbox_json_dcim_module_bay_templates_list.go b/netbox/data_netbox_json_dcim_module_bay_templates_list.go index 5219db6b1..b47930900 100644 --- a/netbox/data_netbox_json_dcim_module_bay_templates_list.go +++ b/netbox/data_netbox_json_dcim_module_bay_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimModuleBayTemplatesListRead(d *schema.ResourceData, m inte return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimModuleBayTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimModuleBayTemplatesList") diff --git a/netbox/data_netbox_json_dcim_module_bays_list.go b/netbox/data_netbox_json_dcim_module_bays_list.go index c21f9870d..e3e0cb0b2 100644 --- a/netbox/data_netbox_json_dcim_module_bays_list.go +++ b/netbox/data_netbox_json_dcim_module_bays_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimModuleBaysListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimModuleBaysList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimModuleBaysList") diff --git a/netbox/data_netbox_json_dcim_module_types_list.go b/netbox/data_netbox_json_dcim_module_types_list.go index 3bc0c55bf..0f5b47df7 100644 --- a/netbox/data_netbox_json_dcim_module_types_list.go +++ b/netbox/data_netbox_json_dcim_module_types_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimModuleTypesListRead(d *schema.ResourceData, m interface{} return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimModuleTypesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimModuleTypesList") diff --git a/netbox/data_netbox_json_dcim_modules_list.go b/netbox/data_netbox_json_dcim_modules_list.go index 37b1b40d2..d9afa05fd 100644 --- a/netbox/data_netbox_json_dcim_modules_list.go +++ b/netbox/data_netbox_json_dcim_modules_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimModulesListRead(d *schema.ResourceData, m interface{}) er return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimModulesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimModulesList") diff --git a/netbox/data_netbox_json_dcim_platforms_list.go b/netbox/data_netbox_json_dcim_platforms_list.go index 58f79abe8..3cdc4914c 100644 --- a/netbox/data_netbox_json_dcim_platforms_list.go +++ b/netbox/data_netbox_json_dcim_platforms_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimPlatformsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimPlatformsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimPlatformsList") diff --git a/netbox/data_netbox_json_dcim_power_feeds_list.go b/netbox/data_netbox_json_dcim_power_feeds_list.go index 2230f3734..925ccea94 100644 --- a/netbox/data_netbox_json_dcim_power_feeds_list.go +++ b/netbox/data_netbox_json_dcim_power_feeds_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimPowerFeedsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimPowerFeedsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimPowerFeedsList") diff --git a/netbox/data_netbox_json_dcim_power_outlet_templates_list.go b/netbox/data_netbox_json_dcim_power_outlet_templates_list.go index 89af98e89..f8c475b9a 100644 --- a/netbox/data_netbox_json_dcim_power_outlet_templates_list.go +++ b/netbox/data_netbox_json_dcim_power_outlet_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimPowerOutletTemplatesListRead(d *schema.ResourceData, m in return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimPowerOutletTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimPowerOutletTemplatesList") diff --git a/netbox/data_netbox_json_dcim_power_outlets_list.go b/netbox/data_netbox_json_dcim_power_outlets_list.go index 3a6db37e0..7d5e9cd5b 100644 --- a/netbox/data_netbox_json_dcim_power_outlets_list.go +++ b/netbox/data_netbox_json_dcim_power_outlets_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimPowerOutletsListRead(d *schema.ResourceData, m interface{ return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimPowerOutletsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimPowerOutletsList") diff --git a/netbox/data_netbox_json_dcim_power_panels_list.go b/netbox/data_netbox_json_dcim_power_panels_list.go index 98006499b..9ba29ce00 100644 --- a/netbox/data_netbox_json_dcim_power_panels_list.go +++ b/netbox/data_netbox_json_dcim_power_panels_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimPowerPanelsListRead(d *schema.ResourceData, m interface{} return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimPowerPanelsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimPowerPanelsList") diff --git a/netbox/data_netbox_json_dcim_power_port_templates_list.go b/netbox/data_netbox_json_dcim_power_port_templates_list.go index ecc38886f..95e44e199 100644 --- a/netbox/data_netbox_json_dcim_power_port_templates_list.go +++ b/netbox/data_netbox_json_dcim_power_port_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimPowerPortTemplatesListRead(d *schema.ResourceData, m inte return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimPowerPortTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimPowerPortTemplatesList") diff --git a/netbox/data_netbox_json_dcim_power_ports_list.go b/netbox/data_netbox_json_dcim_power_ports_list.go index 9783865f8..5a382b936 100644 --- a/netbox/data_netbox_json_dcim_power_ports_list.go +++ b/netbox/data_netbox_json_dcim_power_ports_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimPowerPortsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimPowerPortsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimPowerPortsList") diff --git a/netbox/data_netbox_json_dcim_rack_reservations_list.go b/netbox/data_netbox_json_dcim_rack_reservations_list.go index 2c75ff02a..c57e11876 100644 --- a/netbox/data_netbox_json_dcim_rack_reservations_list.go +++ b/netbox/data_netbox_json_dcim_rack_reservations_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimRackReservationsListRead(d *schema.ResourceData, m interf return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimRackReservationsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimRackReservationsList") diff --git a/netbox/data_netbox_json_dcim_rack_roles_list.go b/netbox/data_netbox_json_dcim_rack_roles_list.go index 843352e3f..6a2b07029 100644 --- a/netbox/data_netbox_json_dcim_rack_roles_list.go +++ b/netbox/data_netbox_json_dcim_rack_roles_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimRackRolesListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimRackRolesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimRackRolesList") diff --git a/netbox/data_netbox_json_dcim_racks_list.go b/netbox/data_netbox_json_dcim_racks_list.go index ff8509f3b..b99990ab0 100644 --- a/netbox/data_netbox_json_dcim_racks_list.go +++ b/netbox/data_netbox_json_dcim_racks_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimRacksListRead(d *schema.ResourceData, m interface{}) erro return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimRacksList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimRacksList") diff --git a/netbox/data_netbox_json_dcim_rear_port_templates_list.go b/netbox/data_netbox_json_dcim_rear_port_templates_list.go index 50cc41b42..fb313a469 100644 --- a/netbox/data_netbox_json_dcim_rear_port_templates_list.go +++ b/netbox/data_netbox_json_dcim_rear_port_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimRearPortTemplatesListRead(d *schema.ResourceData, m inter return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimRearPortTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimRearPortTemplatesList") diff --git a/netbox/data_netbox_json_dcim_rear_ports_list.go b/netbox/data_netbox_json_dcim_rear_ports_list.go index 5025f76c2..2e4efaccd 100644 --- a/netbox/data_netbox_json_dcim_rear_ports_list.go +++ b/netbox/data_netbox_json_dcim_rear_ports_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimRearPortsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimRearPortsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimRearPortsList") diff --git a/netbox/data_netbox_json_dcim_regions_list.go b/netbox/data_netbox_json_dcim_regions_list.go index ebbc71497..42110d250 100644 --- a/netbox/data_netbox_json_dcim_regions_list.go +++ b/netbox/data_netbox_json_dcim_regions_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimRegionsListRead(d *schema.ResourceData, m interface{}) er return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimRegionsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimRegionsList") diff --git a/netbox/data_netbox_json_dcim_site_groups_list.go b/netbox/data_netbox_json_dcim_site_groups_list.go index 0881af47d..46d176b56 100644 --- a/netbox/data_netbox_json_dcim_site_groups_list.go +++ b/netbox/data_netbox_json_dcim_site_groups_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimSiteGroupsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimSiteGroupsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimSiteGroupsList") diff --git a/netbox/data_netbox_json_dcim_sites_list.go b/netbox/data_netbox_json_dcim_sites_list.go index f3981b54f..a6d190b92 100644 --- a/netbox/data_netbox_json_dcim_sites_list.go +++ b/netbox/data_netbox_json_dcim_sites_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimSitesListRead(d *schema.ResourceData, m interface{}) erro return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimSitesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimSitesList") diff --git a/netbox/data_netbox_json_dcim_virtual_chassis_list.go b/netbox/data_netbox_json_dcim_virtual_chassis_list.go index d4a818814..37f1e1ccd 100644 --- a/netbox/data_netbox_json_dcim_virtual_chassis_list.go +++ b/netbox/data_netbox_json_dcim_virtual_chassis_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONDcimVirtualChassisListRead(d *schema.ResourceData, m interfac return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Dcim.DcimVirtualChassisList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONDcimVirtualChassisList") diff --git a/netbox/data_netbox_json_extras_config_contexts_list.go b/netbox/data_netbox_json_extras_config_contexts_list.go index 512c4d2c2..6cf49dd68 100644 --- a/netbox/data_netbox_json_extras_config_contexts_list.go +++ b/netbox/data_netbox_json_extras_config_contexts_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasConfigContextsListRead(d *schema.ResourceData, m interf return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasConfigContextsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasConfigContextsList") diff --git a/netbox/data_netbox_json_extras_content_types_list.go b/netbox/data_netbox_json_extras_content_types_list.go index 254592930..3b3112955 100644 --- a/netbox/data_netbox_json_extras_content_types_list.go +++ b/netbox/data_netbox_json_extras_content_types_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasContentTypesListRead(d *schema.ResourceData, m interfac return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasContentTypesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasContentTypesList") diff --git a/netbox/data_netbox_json_extras_custom_fields_list.go b/netbox/data_netbox_json_extras_custom_fields_list.go index 6cd0dd5a0..94427a72f 100644 --- a/netbox/data_netbox_json_extras_custom_fields_list.go +++ b/netbox/data_netbox_json_extras_custom_fields_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasCustomFieldsListRead(d *schema.ResourceData, m interfac return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasCustomFieldsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasCustomFieldsList") diff --git a/netbox/data_netbox_json_extras_custom_links_list.go b/netbox/data_netbox_json_extras_custom_links_list.go index 14052b2b4..8d3ff6325 100644 --- a/netbox/data_netbox_json_extras_custom_links_list.go +++ b/netbox/data_netbox_json_extras_custom_links_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasCustomLinksListRead(d *schema.ResourceData, m interface return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasCustomLinksList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasCustomLinksList") diff --git a/netbox/data_netbox_json_extras_export_templates_list.go b/netbox/data_netbox_json_extras_export_templates_list.go index 8df8af45c..8822ae5dd 100644 --- a/netbox/data_netbox_json_extras_export_templates_list.go +++ b/netbox/data_netbox_json_extras_export_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasExportTemplatesListRead(d *schema.ResourceData, m inter return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasExportTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasExportTemplatesList") diff --git a/netbox/data_netbox_json_extras_image_attachments_list.go b/netbox/data_netbox_json_extras_image_attachments_list.go index d8f29fc3b..2ce63d961 100644 --- a/netbox/data_netbox_json_extras_image_attachments_list.go +++ b/netbox/data_netbox_json_extras_image_attachments_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasImageAttachmentsListRead(d *schema.ResourceData, m inte return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasImageAttachmentsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasImageAttachmentsList") diff --git a/netbox/data_netbox_json_extras_job_results_list.go b/netbox/data_netbox_json_extras_job_results_list.go index 5aa32f696..fd6ba4f5d 100644 --- a/netbox/data_netbox_json_extras_job_results_list.go +++ b/netbox/data_netbox_json_extras_job_results_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasJobResultsListRead(d *schema.ResourceData, m interface{ return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasJobResultsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasJobResultsList") diff --git a/netbox/data_netbox_json_extras_journal_entries_list.go b/netbox/data_netbox_json_extras_journal_entries_list.go index 67d4250be..72817e117 100644 --- a/netbox/data_netbox_json_extras_journal_entries_list.go +++ b/netbox/data_netbox_json_extras_journal_entries_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasJournalEntriesListRead(d *schema.ResourceData, m interf return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasJournalEntriesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasJournalEntriesList") diff --git a/netbox/data_netbox_json_extras_object_changes_list.go b/netbox/data_netbox_json_extras_object_changes_list.go index 51d023336..3901c5a3a 100644 --- a/netbox/data_netbox_json_extras_object_changes_list.go +++ b/netbox/data_netbox_json_extras_object_changes_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasObjectChangesListRead(d *schema.ResourceData, m interfa return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasObjectChangesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasObjectChangesList") diff --git a/netbox/data_netbox_json_extras_tags_list.go b/netbox/data_netbox_json_extras_tags_list.go index b308b8b97..d0f786105 100644 --- a/netbox/data_netbox_json_extras_tags_list.go +++ b/netbox/data_netbox_json_extras_tags_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasTagsListRead(d *schema.ResourceData, m interface{}) err return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasTagsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasTagsList") diff --git a/netbox/data_netbox_json_extras_webhooks_list.go b/netbox/data_netbox_json_extras_webhooks_list.go index b1889f374..25a295307 100644 --- a/netbox/data_netbox_json_extras_webhooks_list.go +++ b/netbox/data_netbox_json_extras_webhooks_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONExtrasWebhooksListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Extras.ExtrasWebhooksList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONExtrasWebhooksList") diff --git a/netbox/data_netbox_json_ipam_aggregates_list.go b/netbox/data_netbox_json_ipam_aggregates_list.go index c2f422a53..62fa5ad22 100644 --- a/netbox/data_netbox_json_ipam_aggregates_list.go +++ b/netbox/data_netbox_json_ipam_aggregates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamAggregatesListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamAggregatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamAggregatesList") diff --git a/netbox/data_netbox_json_ipam_asns_list.go b/netbox/data_netbox_json_ipam_asns_list.go index 276c9fa41..bf1eed959 100644 --- a/netbox/data_netbox_json_ipam_asns_list.go +++ b/netbox/data_netbox_json_ipam_asns_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamAsnsListRead(d *schema.ResourceData, m interface{}) error return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamAsnsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamAsnsList") diff --git a/netbox/data_netbox_json_ipam_fhrp_group_assignments_list.go b/netbox/data_netbox_json_ipam_fhrp_group_assignments_list.go index 32ded73ff..898842e7c 100644 --- a/netbox/data_netbox_json_ipam_fhrp_group_assignments_list.go +++ b/netbox/data_netbox_json_ipam_fhrp_group_assignments_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamFhrpGroupAssignmentsListRead(d *schema.ResourceData, m in return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamFhrpGroupAssignmentsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamFhrpGroupAssignmentsList") diff --git a/netbox/data_netbox_json_ipam_fhrp_groups_list.go b/netbox/data_netbox_json_ipam_fhrp_groups_list.go index 1c1b8f260..4d2c82088 100644 --- a/netbox/data_netbox_json_ipam_fhrp_groups_list.go +++ b/netbox/data_netbox_json_ipam_fhrp_groups_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamFhrpGroupsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamFhrpGroupsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamFhrpGroupsList") diff --git a/netbox/data_netbox_json_ipam_ip_addresses_list.go b/netbox/data_netbox_json_ipam_ip_addresses_list.go index d08383b8d..692b3411a 100644 --- a/netbox/data_netbox_json_ipam_ip_addresses_list.go +++ b/netbox/data_netbox_json_ipam_ip_addresses_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamIPAddressesListRead(d *schema.ResourceData, m interface{} return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamIPAddressesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamIPAddressesList") diff --git a/netbox/data_netbox_json_ipam_ip_ranges_list.go b/netbox/data_netbox_json_ipam_ip_ranges_list.go index c1ec2d447..76c528a6c 100644 --- a/netbox/data_netbox_json_ipam_ip_ranges_list.go +++ b/netbox/data_netbox_json_ipam_ip_ranges_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamIPRangesListRead(d *schema.ResourceData, m interface{}) e return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamIPRangesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamIPRangesList") diff --git a/netbox/data_netbox_json_ipam_prefixes_list.go b/netbox/data_netbox_json_ipam_prefixes_list.go index 8a1b90903..9d6d4f901 100644 --- a/netbox/data_netbox_json_ipam_prefixes_list.go +++ b/netbox/data_netbox_json_ipam_prefixes_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamPrefixesListRead(d *schema.ResourceData, m interface{}) e return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamPrefixesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamPrefixesList") diff --git a/netbox/data_netbox_json_ipam_rirs_list.go b/netbox/data_netbox_json_ipam_rirs_list.go index 366594962..eb7ddacbb 100644 --- a/netbox/data_netbox_json_ipam_rirs_list.go +++ b/netbox/data_netbox_json_ipam_rirs_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamRirsListRead(d *schema.ResourceData, m interface{}) error return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamRirsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamRirsList") diff --git a/netbox/data_netbox_json_ipam_roles_list.go b/netbox/data_netbox_json_ipam_roles_list.go index fe88fbd4f..1c07346cb 100644 --- a/netbox/data_netbox_json_ipam_roles_list.go +++ b/netbox/data_netbox_json_ipam_roles_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamRolesListRead(d *schema.ResourceData, m interface{}) erro return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamRolesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamRolesList") diff --git a/netbox/data_netbox_json_ipam_route_targets_list.go b/netbox/data_netbox_json_ipam_route_targets_list.go index 8250965ac..76352ca49 100644 --- a/netbox/data_netbox_json_ipam_route_targets_list.go +++ b/netbox/data_netbox_json_ipam_route_targets_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamRouteTargetsListRead(d *schema.ResourceData, m interface{ return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamRouteTargetsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamRouteTargetsList") diff --git a/netbox/data_netbox_json_ipam_service_templates_list.go b/netbox/data_netbox_json_ipam_service_templates_list.go index 0c6cd649b..26ff008db 100644 --- a/netbox/data_netbox_json_ipam_service_templates_list.go +++ b/netbox/data_netbox_json_ipam_service_templates_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamServiceTemplatesListRead(d *schema.ResourceData, m interf return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamServiceTemplatesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamServiceTemplatesList") diff --git a/netbox/data_netbox_json_ipam_services_list.go b/netbox/data_netbox_json_ipam_services_list.go index a6690f492..5b4391235 100644 --- a/netbox/data_netbox_json_ipam_services_list.go +++ b/netbox/data_netbox_json_ipam_services_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamServicesListRead(d *schema.ResourceData, m interface{}) e return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamServicesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamServicesList") diff --git a/netbox/data_netbox_json_ipam_vlan_groups_list.go b/netbox/data_netbox_json_ipam_vlan_groups_list.go index 5e6518be8..326499341 100644 --- a/netbox/data_netbox_json_ipam_vlan_groups_list.go +++ b/netbox/data_netbox_json_ipam_vlan_groups_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamVlanGroupsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamVlanGroupsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamVlanGroupsList") diff --git a/netbox/data_netbox_json_ipam_vlans_list.go b/netbox/data_netbox_json_ipam_vlans_list.go index 64264086d..2116c3b34 100644 --- a/netbox/data_netbox_json_ipam_vlans_list.go +++ b/netbox/data_netbox_json_ipam_vlans_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamVlansListRead(d *schema.ResourceData, m interface{}) erro return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamVlansList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamVlansList") diff --git a/netbox/data_netbox_json_ipam_vrfs_list.go b/netbox/data_netbox_json_ipam_vrfs_list.go index 025204ce4..705513a6a 100644 --- a/netbox/data_netbox_json_ipam_vrfs_list.go +++ b/netbox/data_netbox_json_ipam_vrfs_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONIpamVrfsListRead(d *schema.ResourceData, m interface{}) error return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Ipam.IpamVrfsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONIpamVrfsList") diff --git a/netbox/data_netbox_json_tenancy_contact_assignments_list.go b/netbox/data_netbox_json_tenancy_contact_assignments_list.go index 4cf56cde7..01fcd3c88 100644 --- a/netbox/data_netbox_json_tenancy_contact_assignments_list.go +++ b/netbox/data_netbox_json_tenancy_contact_assignments_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONTenancyContactAssignmentsListRead(d *schema.ResourceData, m i return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Tenancy.TenancyContactAssignmentsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONTenancyContactAssignmentsList") diff --git a/netbox/data_netbox_json_tenancy_contact_groups_list.go b/netbox/data_netbox_json_tenancy_contact_groups_list.go index 8eda4bd6e..8629905c8 100644 --- a/netbox/data_netbox_json_tenancy_contact_groups_list.go +++ b/netbox/data_netbox_json_tenancy_contact_groups_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONTenancyContactGroupsListRead(d *schema.ResourceData, m interf return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Tenancy.TenancyContactGroupsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONTenancyContactGroupsList") diff --git a/netbox/data_netbox_json_tenancy_contact_roles_list.go b/netbox/data_netbox_json_tenancy_contact_roles_list.go index 64d1ba7d9..6d5babd8f 100644 --- a/netbox/data_netbox_json_tenancy_contact_roles_list.go +++ b/netbox/data_netbox_json_tenancy_contact_roles_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONTenancyContactRolesListRead(d *schema.ResourceData, m interfa return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Tenancy.TenancyContactRolesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONTenancyContactRolesList") diff --git a/netbox/data_netbox_json_tenancy_contacts_list.go b/netbox/data_netbox_json_tenancy_contacts_list.go index 4cba505c3..984904f88 100644 --- a/netbox/data_netbox_json_tenancy_contacts_list.go +++ b/netbox/data_netbox_json_tenancy_contacts_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONTenancyContactsListRead(d *schema.ResourceData, m interface{} return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Tenancy.TenancyContactsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONTenancyContactsList") diff --git a/netbox/data_netbox_json_tenancy_tenant_groups_list.go b/netbox/data_netbox_json_tenancy_tenant_groups_list.go index cdc398915..5afbb38df 100644 --- a/netbox/data_netbox_json_tenancy_tenant_groups_list.go +++ b/netbox/data_netbox_json_tenancy_tenant_groups_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONTenancyTenantGroupsListRead(d *schema.ResourceData, m interfa return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Tenancy.TenancyTenantGroupsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONTenancyTenantGroupsList") diff --git a/netbox/data_netbox_json_tenancy_tenants_list.go b/netbox/data_netbox_json_tenancy_tenants_list.go index ea46fe766..88f7ad702 100644 --- a/netbox/data_netbox_json_tenancy_tenants_list.go +++ b/netbox/data_netbox_json_tenancy_tenants_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONTenancyTenantsListRead(d *schema.ResourceData, m interface{}) return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Tenancy.TenancyTenantsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONTenancyTenantsList") diff --git a/netbox/data_netbox_json_users_groups_list.go b/netbox/data_netbox_json_users_groups_list.go index 803f18722..e1e393750 100644 --- a/netbox/data_netbox_json_users_groups_list.go +++ b/netbox/data_netbox_json_users_groups_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONUsersGroupsListRead(d *schema.ResourceData, m interface{}) er return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Users.UsersGroupsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONUsersGroupsList") diff --git a/netbox/data_netbox_json_users_permissions_list.go b/netbox/data_netbox_json_users_permissions_list.go index fd589d337..c7a24847b 100644 --- a/netbox/data_netbox_json_users_permissions_list.go +++ b/netbox/data_netbox_json_users_permissions_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONUsersPermissionsListRead(d *schema.ResourceData, m interface{ return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Users.UsersPermissionsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONUsersPermissionsList") diff --git a/netbox/data_netbox_json_users_tokens_list.go b/netbox/data_netbox_json_users_tokens_list.go index b38a1f57c..a7a77ecf1 100644 --- a/netbox/data_netbox_json_users_tokens_list.go +++ b/netbox/data_netbox_json_users_tokens_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONUsersTokensListRead(d *schema.ResourceData, m interface{}) er return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Users.UsersTokensList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONUsersTokensList") diff --git a/netbox/data_netbox_json_users_users_list.go b/netbox/data_netbox_json_users_users_list.go index 9354c262a..7d2c8a7c1 100644 --- a/netbox/data_netbox_json_users_users_list.go +++ b/netbox/data_netbox_json_users_users_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONUsersUsersListRead(d *schema.ResourceData, m interface{}) err return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Users.UsersUsersList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONUsersUsersList") diff --git a/netbox/data_netbox_json_virtualization_cluster_groups_list.go b/netbox/data_netbox_json_virtualization_cluster_groups_list.go index f99ffeed5..b5c4c48c1 100644 --- a/netbox/data_netbox_json_virtualization_cluster_groups_list.go +++ b/netbox/data_netbox_json_virtualization_cluster_groups_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONVirtualizationClusterGroupsListRead(d *schema.ResourceData, m return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Virtualization.VirtualizationClusterGroupsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONVirtualizationClusterGroupsList") diff --git a/netbox/data_netbox_json_virtualization_cluster_types_list.go b/netbox/data_netbox_json_virtualization_cluster_types_list.go index 7597f74b4..06160f3ef 100644 --- a/netbox/data_netbox_json_virtualization_cluster_types_list.go +++ b/netbox/data_netbox_json_virtualization_cluster_types_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONVirtualizationClusterTypesListRead(d *schema.ResourceData, m return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Virtualization.VirtualizationClusterTypesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONVirtualizationClusterTypesList") diff --git a/netbox/data_netbox_json_virtualization_clusters_list.go b/netbox/data_netbox_json_virtualization_clusters_list.go index 8c09ad33c..e45413d0c 100644 --- a/netbox/data_netbox_json_virtualization_clusters_list.go +++ b/netbox/data_netbox_json_virtualization_clusters_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONVirtualizationClustersListRead(d *schema.ResourceData, m inte return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Virtualization.VirtualizationClustersList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONVirtualizationClustersList") diff --git a/netbox/data_netbox_json_virtualization_interfaces_list.go b/netbox/data_netbox_json_virtualization_interfaces_list.go index b0d638890..89cfefbb6 100644 --- a/netbox/data_netbox_json_virtualization_interfaces_list.go +++ b/netbox/data_netbox_json_virtualization_interfaces_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONVirtualizationInterfacesListRead(d *schema.ResourceData, m in return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Virtualization.VirtualizationInterfacesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONVirtualizationInterfacesList") diff --git a/netbox/data_netbox_json_virtualization_virtual_machines_list.go b/netbox/data_netbox_json_virtualization_virtual_machines_list.go index 4b9e8c9bf..a32dcace0 100644 --- a/netbox/data_netbox_json_virtualization_virtual_machines_list.go +++ b/netbox/data_netbox_json_virtualization_virtual_machines_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONVirtualizationVirtualMachinesListRead(d *schema.ResourceData, return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Virtualization.VirtualizationVirtualMachinesList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONVirtualizationVirtualMachinesList") diff --git a/netbox/data_netbox_json_wireless_wireless_lan_groups_list.go b/netbox/data_netbox_json_wireless_wireless_lan_groups_list.go index c622f30e0..cc4f16aae 100644 --- a/netbox/data_netbox_json_wireless_wireless_lan_groups_list.go +++ b/netbox/data_netbox_json_wireless_wireless_lan_groups_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONWirelessWirelessLanGroupsListRead(d *schema.ResourceData, m i return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Wireless.WirelessWirelessLanGroupsList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONWirelessWirelessLanGroupsList") diff --git a/netbox/data_netbox_json_wireless_wireless_lans_list.go b/netbox/data_netbox_json_wireless_wireless_lans_list.go index b4d15a392..8dfe44f54 100644 --- a/netbox/data_netbox_json_wireless_wireless_lans_list.go +++ b/netbox/data_netbox_json_wireless_wireless_lans_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONWirelessWirelessLansListRead(d *schema.ResourceData, m interf return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Wireless.WirelessWirelessLansList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONWirelessWirelessLansList") diff --git a/netbox/data_netbox_json_wireless_wireless_links_list.go b/netbox/data_netbox_json_wireless_wireless_links_list.go index ee3d81ea2..590274302 100644 --- a/netbox/data_netbox_json_wireless_wireless_links_list.go +++ b/netbox/data_netbox_json_wireless_wireless_links_list.go @@ -41,7 +41,30 @@ func dataNetboxJSONWirelessWirelessLinksListRead(d *schema.ResourceData, m inter return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.Wireless.WirelessWirelessLinksList(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSONWirelessWirelessLinksList") diff --git a/utils/generateJsonDatasources b/utils/generateJsonDatasources index caeb93bfc..2bebee4f3 100755 --- a/utils/generateJsonDatasources +++ b/utils/generateJsonDatasources @@ -124,7 +124,30 @@ func dataNetboxJSON${SECTION}${ITEM}ListRead(d *schema.ResourceData, m interface return err } - j, _ := json.Marshal(list.Payload.Results) + tmp := list.Payload.Results + resultLength := int64(len(tmp)) + desiredLength := *list.Payload.Count + if limit > 0 && limit < desiredLength { + desiredLength = limit + } + if limit == 0 || resultLength < desiredLength { + limit = resultLength + } + offset := limit + params.Offset = &offset + for int64(len(tmp)) < desiredLength { + offset = int64(len(tmp)) + if limit > desiredLength - offset { + limit = desiredLength - offset + } + list, err = client.${SECTION}.${SECTION}${ITEM}List(params, nil) + if err != nil { + return err + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) d.Set("json", string(j)) d.SetId("NetboxJSON${SECTION}${ITEM}List")