From 345f1ad09b067fde167e03cd57c03f3f24f5e2d1 Mon Sep 17 00:00:00 2001 From: Samuel Mutel <12967891+smutel@users.noreply.github.com> Date: Mon, 30 Jan 2023 12:02:38 +0100 Subject: [PATCH] feat: Add filter to JSON data sources --- .../data-source.tf | 7 ++ .../data-source.tf | 7 ++ .../data-source.tf | 7 ++ netbox/internal/util/util.go | 9 ++ ...json_circuits_circuit_terminations_list.go | 37 ++++++ ...netbox_json_circuits_circuit_types_list.go | 37 ++++++ ...data_netbox_json_circuits_circuits_list.go | 37 ++++++ ...ox_json_circuits_provider_networks_list.go | 37 ++++++ ...ata_netbox_json_circuits_providers_list.go | 37 ++++++ ...etbox_json_dcim_cable_terminations_list.go | 118 ++++++++++++++++++ .../json/data_netbox_json_dcim_cables_list.go | 37 ++++++ ...x_json_dcim_console_port_templates_list.go | 37 ++++++ ...ata_netbox_json_dcim_console_ports_list.go | 37 ++++++ ...dcim_console_server_port_templates_list.go | 37 ++++++ ...box_json_dcim_console_server_ports_list.go | 37 ++++++ ...box_json_dcim_device_bay_templates_list.go | 37 ++++++ .../data_netbox_json_dcim_device_bays_list.go | 37 ++++++ ...data_netbox_json_dcim_device_roles_list.go | 37 ++++++ ...data_netbox_json_dcim_device_types_list.go | 37 ++++++ .../data_netbox_json_dcim_devices_list.go | 37 ++++++ ...box_json_dcim_front_port_templates_list.go | 37 ++++++ .../data_netbox_json_dcim_front_ports_list.go | 37 ++++++ ...tbox_json_dcim_interface_templates_list.go | 37 ++++++ .../data_netbox_json_dcim_interfaces_list.go | 37 ++++++ ...box_json_dcim_inventory_item_roles_list.go | 37 ++++++ ...json_dcim_inventory_item_templates_list.go | 37 ++++++ ...a_netbox_json_dcim_inventory_items_list.go | 37 ++++++ .../data_netbox_json_dcim_locations_list.go | 37 ++++++ ...ata_netbox_json_dcim_manufacturers_list.go | 37 ++++++ ...box_json_dcim_module_bay_templates_list.go | 37 ++++++ .../data_netbox_json_dcim_module_bays_list.go | 37 ++++++ ...data_netbox_json_dcim_module_types_list.go | 37 ++++++ .../data_netbox_json_dcim_modules_list.go | 37 ++++++ .../data_netbox_json_dcim_platforms_list.go | 37 ++++++ .../data_netbox_json_dcim_power_feeds_list.go | 37 ++++++ ...x_json_dcim_power_outlet_templates_list.go | 37 ++++++ ...ata_netbox_json_dcim_power_outlets_list.go | 37 ++++++ ...data_netbox_json_dcim_power_panels_list.go | 37 ++++++ ...box_json_dcim_power_port_templates_list.go | 37 ++++++ .../data_netbox_json_dcim_power_ports_list.go | 37 ++++++ ...netbox_json_dcim_rack_reservations_list.go | 37 ++++++ .../data_netbox_json_dcim_rack_roles_list.go | 37 ++++++ .../json/data_netbox_json_dcim_racks_list.go | 37 ++++++ ...tbox_json_dcim_rear_port_templates_list.go | 37 ++++++ .../data_netbox_json_dcim_rear_ports_list.go | 37 ++++++ .../data_netbox_json_dcim_regions_list.go | 37 ++++++ .../data_netbox_json_dcim_site_groups_list.go | 37 ++++++ .../json/data_netbox_json_dcim_sites_list.go | 37 ++++++ ...a_netbox_json_dcim_virtual_chassis_list.go | 37 ++++++ ...netbox_json_extras_config_contexts_list.go | 37 ++++++ ...a_netbox_json_extras_content_types_list.go | 37 ++++++ ...a_netbox_json_extras_custom_fields_list.go | 37 ++++++ ...ta_netbox_json_extras_custom_links_list.go | 37 ++++++ ...etbox_json_extras_export_templates_list.go | 37 ++++++ ...tbox_json_extras_image_attachments_list.go | 37 ++++++ ...ata_netbox_json_extras_job_results_list.go | 37 ++++++ ...netbox_json_extras_journal_entries_list.go | 37 ++++++ ..._netbox_json_extras_object_changes_list.go | 37 ++++++ .../json/data_netbox_json_extras_tags_list.go | 37 ++++++ .../data_netbox_json_extras_webhooks_list.go | 37 ++++++ .../data_netbox_json_ipam_aggregates_list.go | 37 ++++++ .../json/data_netbox_json_ipam_asns_list.go | 37 ++++++ ...x_json_ipam_fhrp_group_assignments_list.go | 37 ++++++ .../data_netbox_json_ipam_fhrp_groups_list.go | 37 ++++++ ...data_netbox_json_ipam_ip_addresses_list.go | 37 ++++++ .../data_netbox_json_ipam_ip_ranges_list.go | 37 ++++++ ...etbox_json_ipam_l2vpn_terminations_list.go | 118 ++++++++++++++++++ .../json/data_netbox_json_ipam_l2vpns_list.go | 118 ++++++++++++++++++ .../data_netbox_json_ipam_prefixes_list.go | 37 ++++++ .../json/data_netbox_json_ipam_rirs_list.go | 37 ++++++ .../json/data_netbox_json_ipam_roles_list.go | 37 ++++++ ...ata_netbox_json_ipam_route_targets_list.go | 37 ++++++ ...netbox_json_ipam_service_templates_list.go | 37 ++++++ .../data_netbox_json_ipam_services_list.go | 37 ++++++ .../data_netbox_json_ipam_vlan_groups_list.go | 37 ++++++ .../json/data_netbox_json_ipam_vlans_list.go | 37 ++++++ .../json/data_netbox_json_ipam_vrfs_list.go | 37 ++++++ ...x_json_tenancy_contact_assignments_list.go | 37 ++++++ ...netbox_json_tenancy_contact_groups_list.go | 37 ++++++ ..._netbox_json_tenancy_contact_roles_list.go | 37 ++++++ .../data_netbox_json_tenancy_contacts_list.go | 37 ++++++ ..._netbox_json_tenancy_tenant_groups_list.go | 37 ++++++ .../data_netbox_json_tenancy_tenants_list.go | 37 ++++++ .../data_netbox_json_users_groups_list.go | 37 ++++++ ...data_netbox_json_users_permissions_list.go | 37 ++++++ .../data_netbox_json_users_tokens_list.go | 37 ++++++ .../json/data_netbox_json_users_users_list.go | 37 ++++++ ...json_virtualization_cluster_groups_list.go | 37 ++++++ ..._json_virtualization_cluster_types_list.go | 37 ++++++ ...etbox_json_virtualization_clusters_list.go | 37 ++++++ ...box_json_virtualization_interfaces_list.go | 37 ++++++ ...on_virtualization_virtual_machines_list.go | 37 ++++++ ..._json_wireless_wireless_lan_groups_list.go | 37 ++++++ ...netbox_json_wireless_wireless_lans_list.go | 37 ++++++ ...etbox_json_wireless_wireless_links_list.go | 37 ++++++ netbox/provider.go | 3 + utils/generateJsonDatasources | 37 ++++++ 97 files changed, 3680 insertions(+) create mode 100644 examples/data-sources/netbox_json_dcim_cable_terminations_list/data-source.tf create mode 100644 examples/data-sources/netbox_json_ipam_l2vpn_terminations_list/data-source.tf create mode 100644 examples/data-sources/netbox_json_ipam_l2vpns_list/data-source.tf create mode 100644 netbox/json/data_netbox_json_dcim_cable_terminations_list.go create mode 100644 netbox/json/data_netbox_json_ipam_l2vpn_terminations_list.go create mode 100644 netbox/json/data_netbox_json_ipam_l2vpns_list.go diff --git a/examples/data-sources/netbox_json_dcim_cable_terminations_list/data-source.tf b/examples/data-sources/netbox_json_dcim_cable_terminations_list/data-source.tf new file mode 100644 index 000000000..e1dd919dd --- /dev/null +++ b/examples/data-sources/netbox_json_dcim_cable_terminations_list/data-source.tf @@ -0,0 +1,7 @@ +data "netbox_json_dcim_cable_terminations_list" "test" { + limit = 0 +} + +output "example" { + value = jsondecode(data.netbox_json_dcim_cable_terminations_list.test.json) +} diff --git a/examples/data-sources/netbox_json_ipam_l2vpn_terminations_list/data-source.tf b/examples/data-sources/netbox_json_ipam_l2vpn_terminations_list/data-source.tf new file mode 100644 index 000000000..d1b34bbcf --- /dev/null +++ b/examples/data-sources/netbox_json_ipam_l2vpn_terminations_list/data-source.tf @@ -0,0 +1,7 @@ +data "netbox_json_ipam_l2vpn_terminations_list" "test" { + limit = 0 +} + +output "example" { + value = jsondecode(data.netbox_json_ipam_l2vpn_terminations_list.test.json) +} diff --git a/examples/data-sources/netbox_json_ipam_l2vpns_list/data-source.tf b/examples/data-sources/netbox_json_ipam_l2vpns_list/data-source.tf new file mode 100644 index 000000000..d9ca14692 --- /dev/null +++ b/examples/data-sources/netbox_json_ipam_l2vpns_list/data-source.tf @@ -0,0 +1,7 @@ +data "netbox_json_ipam_l2vpns_list" "test" { + limit = 0 +} + +output "example" { + value = jsondecode(data.netbox_json_ipam_l2vpns_list.test.json) +} diff --git a/netbox/internal/util/util.go b/netbox/internal/util/util.go index 52a2f2038..1fc8b3319 100644 --- a/netbox/internal/util/util.go +++ b/netbox/internal/util/util.go @@ -5,6 +5,7 @@ import ( "fmt" "regexp" "strings" + "unicode" "github.com/go-openapi/strfmt" "github.com/smutel/go-netbox/v3/netbox/models" @@ -87,3 +88,11 @@ func ToListofStrings(in []interface{}) []string { func TrimString(val interface{}) string { return strings.TrimSpace(val.(string)) } + +func FieldNameToStructName(k string) string { + r := []rune(k) + r[0] = unicode.ToUpper(r[0]) + k = string(r) + k = strings.Replace(k, "_", "", -1) + return k +} diff --git a/netbox/json/data_netbox_json_circuits_circuit_terminations_list.go b/netbox/json/data_netbox_json_circuits_circuit_terminations_list.go index 69d474e8a..a4cc70421 100644 --- a/netbox/json/data_netbox_json_circuits_circuit_terminations_list.go +++ b/netbox/json/data_netbox_json_circuits_circuit_terminations_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/circuits" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONCircuitsCircuitTerminationsList() *schema.Resource { ReadContext: dataNetboxJSONCircuitsCircuitTerminationsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONCircuitsCircuitTerminationsListRead(ctx context.Context, d *s limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Circuits.CircuitsCircuitTerminationsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_circuits_circuit_types_list.go b/netbox/json/data_netbox_json_circuits_circuit_types_list.go index 58e5d0e66..0cb37dcec 100644 --- a/netbox/json/data_netbox_json_circuits_circuit_types_list.go +++ b/netbox/json/data_netbox_json_circuits_circuit_types_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/circuits" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONCircuitsCircuitTypesList() *schema.Resource { ReadContext: dataNetboxJSONCircuitsCircuitTypesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONCircuitsCircuitTypesListRead(ctx context.Context, d *schema.R limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Circuits.CircuitsCircuitTypesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_circuits_circuits_list.go b/netbox/json/data_netbox_json_circuits_circuits_list.go index 4707c0db5..aa8d96f6d 100644 --- a/netbox/json/data_netbox_json_circuits_circuits_list.go +++ b/netbox/json/data_netbox_json_circuits_circuits_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/circuits" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONCircuitsCircuitsList() *schema.Resource { ReadContext: dataNetboxJSONCircuitsCircuitsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONCircuitsCircuitsListRead(ctx context.Context, d *schema.Resou limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Circuits.CircuitsCircuitsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_circuits_provider_networks_list.go b/netbox/json/data_netbox_json_circuits_provider_networks_list.go index d604b2509..f2187d6d7 100644 --- a/netbox/json/data_netbox_json_circuits_provider_networks_list.go +++ b/netbox/json/data_netbox_json_circuits_provider_networks_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/circuits" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONCircuitsProviderNetworksList() *schema.Resource { ReadContext: dataNetboxJSONCircuitsProviderNetworksListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONCircuitsProviderNetworksListRead(ctx context.Context, d *sche limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Circuits.CircuitsProviderNetworksList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_circuits_providers_list.go b/netbox/json/data_netbox_json_circuits_providers_list.go index 9e021bb6a..815ae51a8 100644 --- a/netbox/json/data_netbox_json_circuits_providers_list.go +++ b/netbox/json/data_netbox_json_circuits_providers_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/circuits" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONCircuitsProvidersList() *schema.Resource { ReadContext: dataNetboxJSONCircuitsProvidersListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONCircuitsProvidersListRead(ctx context.Context, d *schema.Reso limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Circuits.CircuitsProvidersList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_cable_terminations_list.go b/netbox/json/data_netbox_json_dcim_cable_terminations_list.go new file mode 100644 index 000000000..0fccefcf2 --- /dev/null +++ b/netbox/json/data_netbox_json_dcim_cable_terminations_list.go @@ -0,0 +1,118 @@ +// Code generated by util/generateJsonDatasources; DO NOT EDIT. +package json + +import ( + "context" + "encoding/json" + "reflect" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + netboxclient "github.com/smutel/go-netbox/v3/netbox/client" + "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" +) + +// This file was generated by the util/generateJsonDatasources. +// Editing this file might prove futile when you re-run the util/generateJsonDatasources command + +func DataNetboxJSONDcimCableTerminationsList() *schema.Resource { + return &schema.Resource{ + Description: "Get json output from the dcim_cable_terminations_list Netbox endpoint.", + ReadContext: dataNetboxJSONDcimCableTerminationsListRead, + + Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, + "limit": { + Type: schema.TypeInt, + Optional: true, + Default: 0, + Description: "The max number of returned results. If 0 is specified, all records will be returned.", + }, + "json": { + Type: schema.TypeString, + Computed: true, + Description: "JSON output of the list of objects for this Netbox endpoint.", + }, + }, + } +} + +func dataNetboxJSONDcimCableTerminationsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*netboxclient.NetBoxAPI) + + params := dcim.NewDcimCableTerminationsListParams() + limit := int64(d.Get("limit").(int)) + params.Limit = &limit + + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + + list, err := client.Dcim.DcimCableTerminationsList(params, nil) + if err != nil { + return diag.FromErr(err) + } + + 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.DcimCableTerminationsList(params, nil) + if err != nil { + return diag.FromErr(err) + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) + + if err = d.Set("json", string(j)); err != nil { + return diag.FromErr(err) + } + d.SetId("NetboxJSONDcimCableTerminationsList") + + return nil +} diff --git a/netbox/json/data_netbox_json_dcim_cables_list.go b/netbox/json/data_netbox_json_dcim_cables_list.go index 24a25676b..12a5f3140 100644 --- a/netbox/json/data_netbox_json_dcim_cables_list.go +++ b/netbox/json/data_netbox_json_dcim_cables_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimCablesList() *schema.Resource { ReadContext: dataNetboxJSONDcimCablesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimCablesListRead(ctx context.Context, d *schema.ResourceDat limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimCablesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_console_port_templates_list.go b/netbox/json/data_netbox_json_dcim_console_port_templates_list.go index 46a79144a..f4ba868ea 100644 --- a/netbox/json/data_netbox_json_dcim_console_port_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_console_port_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimConsolePortTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimConsolePortTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimConsolePortTemplatesListRead(ctx context.Context, d *sche limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimConsolePortTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_console_ports_list.go b/netbox/json/data_netbox_json_dcim_console_ports_list.go index 74c057824..b1e9e748e 100644 --- a/netbox/json/data_netbox_json_dcim_console_ports_list.go +++ b/netbox/json/data_netbox_json_dcim_console_ports_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimConsolePortsList() *schema.Resource { ReadContext: dataNetboxJSONDcimConsolePortsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimConsolePortsListRead(ctx context.Context, d *schema.Resou limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimConsolePortsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_console_server_port_templates_list.go b/netbox/json/data_netbox_json_dcim_console_server_port_templates_list.go index 7121b92a4..5157b5677 100644 --- a/netbox/json/data_netbox_json_dcim_console_server_port_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_console_server_port_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimConsoleServerPortTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimConsoleServerPortTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimConsoleServerPortTemplatesListRead(ctx context.Context, d limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimConsoleServerPortTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_console_server_ports_list.go b/netbox/json/data_netbox_json_dcim_console_server_ports_list.go index 544834735..37e2406c0 100644 --- a/netbox/json/data_netbox_json_dcim_console_server_ports_list.go +++ b/netbox/json/data_netbox_json_dcim_console_server_ports_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimConsoleServerPortsList() *schema.Resource { ReadContext: dataNetboxJSONDcimConsoleServerPortsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimConsoleServerPortsListRead(ctx context.Context, d *schema limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimConsoleServerPortsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_device_bay_templates_list.go b/netbox/json/data_netbox_json_dcim_device_bay_templates_list.go index 1be021ddf..c26161d1a 100644 --- a/netbox/json/data_netbox_json_dcim_device_bay_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_device_bay_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimDeviceBayTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimDeviceBayTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimDeviceBayTemplatesListRead(ctx context.Context, d *schema limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimDeviceBayTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_device_bays_list.go b/netbox/json/data_netbox_json_dcim_device_bays_list.go index 359f75543..e9fe519cc 100644 --- a/netbox/json/data_netbox_json_dcim_device_bays_list.go +++ b/netbox/json/data_netbox_json_dcim_device_bays_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimDeviceBaysList() *schema.Resource { ReadContext: dataNetboxJSONDcimDeviceBaysListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimDeviceBaysListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimDeviceBaysList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_device_roles_list.go b/netbox/json/data_netbox_json_dcim_device_roles_list.go index 8ef8029b3..d87585602 100644 --- a/netbox/json/data_netbox_json_dcim_device_roles_list.go +++ b/netbox/json/data_netbox_json_dcim_device_roles_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimDeviceRolesList() *schema.Resource { ReadContext: dataNetboxJSONDcimDeviceRolesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimDeviceRolesListRead(ctx context.Context, d *schema.Resour limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimDeviceRolesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_device_types_list.go b/netbox/json/data_netbox_json_dcim_device_types_list.go index 8350575ba..58ffd182c 100644 --- a/netbox/json/data_netbox_json_dcim_device_types_list.go +++ b/netbox/json/data_netbox_json_dcim_device_types_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimDeviceTypesList() *schema.Resource { ReadContext: dataNetboxJSONDcimDeviceTypesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimDeviceTypesListRead(ctx context.Context, d *schema.Resour limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimDeviceTypesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_devices_list.go b/netbox/json/data_netbox_json_dcim_devices_list.go index f8e6432db..33bb2c3d9 100644 --- a/netbox/json/data_netbox_json_dcim_devices_list.go +++ b/netbox/json/data_netbox_json_dcim_devices_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimDevicesList() *schema.Resource { ReadContext: dataNetboxJSONDcimDevicesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimDevicesListRead(ctx context.Context, d *schema.ResourceDa limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimDevicesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_front_port_templates_list.go b/netbox/json/data_netbox_json_dcim_front_port_templates_list.go index 767ff1792..7390865b0 100644 --- a/netbox/json/data_netbox_json_dcim_front_port_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_front_port_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimFrontPortTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimFrontPortTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimFrontPortTemplatesListRead(ctx context.Context, d *schema limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimFrontPortTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_front_ports_list.go b/netbox/json/data_netbox_json_dcim_front_ports_list.go index 82b95ad9d..b95b37a83 100644 --- a/netbox/json/data_netbox_json_dcim_front_ports_list.go +++ b/netbox/json/data_netbox_json_dcim_front_ports_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimFrontPortsList() *schema.Resource { ReadContext: dataNetboxJSONDcimFrontPortsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimFrontPortsListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimFrontPortsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_interface_templates_list.go b/netbox/json/data_netbox_json_dcim_interface_templates_list.go index 280b144ab..cf2cac355 100644 --- a/netbox/json/data_netbox_json_dcim_interface_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_interface_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimInterfaceTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimInterfaceTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimInterfaceTemplatesListRead(ctx context.Context, d *schema limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimInterfaceTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_interfaces_list.go b/netbox/json/data_netbox_json_dcim_interfaces_list.go index fbfcbbb74..7cf267b25 100644 --- a/netbox/json/data_netbox_json_dcim_interfaces_list.go +++ b/netbox/json/data_netbox_json_dcim_interfaces_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimInterfacesList() *schema.Resource { ReadContext: dataNetboxJSONDcimInterfacesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimInterfacesListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimInterfacesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_inventory_item_roles_list.go b/netbox/json/data_netbox_json_dcim_inventory_item_roles_list.go index ace67903d..799ad31db 100644 --- a/netbox/json/data_netbox_json_dcim_inventory_item_roles_list.go +++ b/netbox/json/data_netbox_json_dcim_inventory_item_roles_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimInventoryItemRolesList() *schema.Resource { ReadContext: dataNetboxJSONDcimInventoryItemRolesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimInventoryItemRolesListRead(ctx context.Context, d *schema limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimInventoryItemRolesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_inventory_item_templates_list.go b/netbox/json/data_netbox_json_dcim_inventory_item_templates_list.go index 75433daaa..9365724f0 100644 --- a/netbox/json/data_netbox_json_dcim_inventory_item_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_inventory_item_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimInventoryItemTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimInventoryItemTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimInventoryItemTemplatesListRead(ctx context.Context, d *sc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimInventoryItemTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_inventory_items_list.go b/netbox/json/data_netbox_json_dcim_inventory_items_list.go index 2d52a73ab..6591d0ade 100644 --- a/netbox/json/data_netbox_json_dcim_inventory_items_list.go +++ b/netbox/json/data_netbox_json_dcim_inventory_items_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimInventoryItemsList() *schema.Resource { ReadContext: dataNetboxJSONDcimInventoryItemsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimInventoryItemsListRead(ctx context.Context, d *schema.Res limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimInventoryItemsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_locations_list.go b/netbox/json/data_netbox_json_dcim_locations_list.go index 1deb6b762..4c99fe214 100644 --- a/netbox/json/data_netbox_json_dcim_locations_list.go +++ b/netbox/json/data_netbox_json_dcim_locations_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimLocationsList() *schema.Resource { ReadContext: dataNetboxJSONDcimLocationsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimLocationsListRead(ctx context.Context, d *schema.Resource limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimLocationsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_manufacturers_list.go b/netbox/json/data_netbox_json_dcim_manufacturers_list.go index 778e126a3..bf5c4a251 100644 --- a/netbox/json/data_netbox_json_dcim_manufacturers_list.go +++ b/netbox/json/data_netbox_json_dcim_manufacturers_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimManufacturersList() *schema.Resource { ReadContext: dataNetboxJSONDcimManufacturersListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimManufacturersListRead(ctx context.Context, d *schema.Reso limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimManufacturersList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_module_bay_templates_list.go b/netbox/json/data_netbox_json_dcim_module_bay_templates_list.go index 2390dd63b..78a6944b6 100644 --- a/netbox/json/data_netbox_json_dcim_module_bay_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_module_bay_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimModuleBayTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimModuleBayTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimModuleBayTemplatesListRead(ctx context.Context, d *schema limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimModuleBayTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_module_bays_list.go b/netbox/json/data_netbox_json_dcim_module_bays_list.go index b86c2eb5c..6c249a2a5 100644 --- a/netbox/json/data_netbox_json_dcim_module_bays_list.go +++ b/netbox/json/data_netbox_json_dcim_module_bays_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimModuleBaysList() *schema.Resource { ReadContext: dataNetboxJSONDcimModuleBaysListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimModuleBaysListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimModuleBaysList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_module_types_list.go b/netbox/json/data_netbox_json_dcim_module_types_list.go index 6366e625f..c6ba58546 100644 --- a/netbox/json/data_netbox_json_dcim_module_types_list.go +++ b/netbox/json/data_netbox_json_dcim_module_types_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimModuleTypesList() *schema.Resource { ReadContext: dataNetboxJSONDcimModuleTypesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimModuleTypesListRead(ctx context.Context, d *schema.Resour limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimModuleTypesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_modules_list.go b/netbox/json/data_netbox_json_dcim_modules_list.go index bc382e4bf..423605be9 100644 --- a/netbox/json/data_netbox_json_dcim_modules_list.go +++ b/netbox/json/data_netbox_json_dcim_modules_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimModulesList() *schema.Resource { ReadContext: dataNetboxJSONDcimModulesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimModulesListRead(ctx context.Context, d *schema.ResourceDa limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimModulesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_platforms_list.go b/netbox/json/data_netbox_json_dcim_platforms_list.go index 4dbd0dd7c..f4a611bc9 100644 --- a/netbox/json/data_netbox_json_dcim_platforms_list.go +++ b/netbox/json/data_netbox_json_dcim_platforms_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimPlatformsList() *schema.Resource { ReadContext: dataNetboxJSONDcimPlatformsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimPlatformsListRead(ctx context.Context, d *schema.Resource limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimPlatformsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_power_feeds_list.go b/netbox/json/data_netbox_json_dcim_power_feeds_list.go index febb060db..c1a9702b1 100644 --- a/netbox/json/data_netbox_json_dcim_power_feeds_list.go +++ b/netbox/json/data_netbox_json_dcim_power_feeds_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimPowerFeedsList() *schema.Resource { ReadContext: dataNetboxJSONDcimPowerFeedsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimPowerFeedsListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimPowerFeedsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_power_outlet_templates_list.go b/netbox/json/data_netbox_json_dcim_power_outlet_templates_list.go index 751711102..837fdc314 100644 --- a/netbox/json/data_netbox_json_dcim_power_outlet_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_power_outlet_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimPowerOutletTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimPowerOutletTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimPowerOutletTemplatesListRead(ctx context.Context, d *sche limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimPowerOutletTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_power_outlets_list.go b/netbox/json/data_netbox_json_dcim_power_outlets_list.go index 7404b2cf9..03ed90111 100644 --- a/netbox/json/data_netbox_json_dcim_power_outlets_list.go +++ b/netbox/json/data_netbox_json_dcim_power_outlets_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimPowerOutletsList() *schema.Resource { ReadContext: dataNetboxJSONDcimPowerOutletsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimPowerOutletsListRead(ctx context.Context, d *schema.Resou limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimPowerOutletsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_power_panels_list.go b/netbox/json/data_netbox_json_dcim_power_panels_list.go index 4ed9b283f..8f7f60dee 100644 --- a/netbox/json/data_netbox_json_dcim_power_panels_list.go +++ b/netbox/json/data_netbox_json_dcim_power_panels_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimPowerPanelsList() *schema.Resource { ReadContext: dataNetboxJSONDcimPowerPanelsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimPowerPanelsListRead(ctx context.Context, d *schema.Resour limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimPowerPanelsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_power_port_templates_list.go b/netbox/json/data_netbox_json_dcim_power_port_templates_list.go index cf2b51cd8..535a60946 100644 --- a/netbox/json/data_netbox_json_dcim_power_port_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_power_port_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimPowerPortTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimPowerPortTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimPowerPortTemplatesListRead(ctx context.Context, d *schema limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimPowerPortTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_power_ports_list.go b/netbox/json/data_netbox_json_dcim_power_ports_list.go index 379fb99b3..30bd09b00 100644 --- a/netbox/json/data_netbox_json_dcim_power_ports_list.go +++ b/netbox/json/data_netbox_json_dcim_power_ports_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimPowerPortsList() *schema.Resource { ReadContext: dataNetboxJSONDcimPowerPortsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimPowerPortsListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimPowerPortsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_rack_reservations_list.go b/netbox/json/data_netbox_json_dcim_rack_reservations_list.go index f505e7454..48cf77fb9 100644 --- a/netbox/json/data_netbox_json_dcim_rack_reservations_list.go +++ b/netbox/json/data_netbox_json_dcim_rack_reservations_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimRackReservationsList() *schema.Resource { ReadContext: dataNetboxJSONDcimRackReservationsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimRackReservationsListRead(ctx context.Context, d *schema.R limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimRackReservationsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_rack_roles_list.go b/netbox/json/data_netbox_json_dcim_rack_roles_list.go index ba60cce0c..2b9feca67 100644 --- a/netbox/json/data_netbox_json_dcim_rack_roles_list.go +++ b/netbox/json/data_netbox_json_dcim_rack_roles_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimRackRolesList() *schema.Resource { ReadContext: dataNetboxJSONDcimRackRolesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimRackRolesListRead(ctx context.Context, d *schema.Resource limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimRackRolesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_racks_list.go b/netbox/json/data_netbox_json_dcim_racks_list.go index f136871c2..7bc1cf78c 100644 --- a/netbox/json/data_netbox_json_dcim_racks_list.go +++ b/netbox/json/data_netbox_json_dcim_racks_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimRacksList() *schema.Resource { ReadContext: dataNetboxJSONDcimRacksListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimRacksListRead(ctx context.Context, d *schema.ResourceData limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimRacksList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_rear_port_templates_list.go b/netbox/json/data_netbox_json_dcim_rear_port_templates_list.go index 18d6e22b8..d5d03fcd9 100644 --- a/netbox/json/data_netbox_json_dcim_rear_port_templates_list.go +++ b/netbox/json/data_netbox_json_dcim_rear_port_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimRearPortTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONDcimRearPortTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimRearPortTemplatesListRead(ctx context.Context, d *schema. limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimRearPortTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_rear_ports_list.go b/netbox/json/data_netbox_json_dcim_rear_ports_list.go index d2c46532a..8386e9901 100644 --- a/netbox/json/data_netbox_json_dcim_rear_ports_list.go +++ b/netbox/json/data_netbox_json_dcim_rear_ports_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimRearPortsList() *schema.Resource { ReadContext: dataNetboxJSONDcimRearPortsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimRearPortsListRead(ctx context.Context, d *schema.Resource limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimRearPortsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_regions_list.go b/netbox/json/data_netbox_json_dcim_regions_list.go index 17fa92865..babb3046b 100644 --- a/netbox/json/data_netbox_json_dcim_regions_list.go +++ b/netbox/json/data_netbox_json_dcim_regions_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimRegionsList() *schema.Resource { ReadContext: dataNetboxJSONDcimRegionsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimRegionsListRead(ctx context.Context, d *schema.ResourceDa limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimRegionsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_site_groups_list.go b/netbox/json/data_netbox_json_dcim_site_groups_list.go index 692ad7d5e..ad9c04845 100644 --- a/netbox/json/data_netbox_json_dcim_site_groups_list.go +++ b/netbox/json/data_netbox_json_dcim_site_groups_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimSiteGroupsList() *schema.Resource { ReadContext: dataNetboxJSONDcimSiteGroupsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimSiteGroupsListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimSiteGroupsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_sites_list.go b/netbox/json/data_netbox_json_dcim_sites_list.go index 99e01089e..b245bb598 100644 --- a/netbox/json/data_netbox_json_dcim_sites_list.go +++ b/netbox/json/data_netbox_json_dcim_sites_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimSitesList() *schema.Resource { ReadContext: dataNetboxJSONDcimSitesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimSitesListRead(ctx context.Context, d *schema.ResourceData limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimSitesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_dcim_virtual_chassis_list.go b/netbox/json/data_netbox_json_dcim_virtual_chassis_list.go index 1efa2e504..35ec115ff 100644 --- a/netbox/json/data_netbox_json_dcim_virtual_chassis_list.go +++ b/netbox/json/data_netbox_json_dcim_virtual_chassis_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/dcim" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONDcimVirtualChassisList() *schema.Resource { ReadContext: dataNetboxJSONDcimVirtualChassisListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONDcimVirtualChassisListRead(ctx context.Context, d *schema.Res limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Dcim.DcimVirtualChassisList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_config_contexts_list.go b/netbox/json/data_netbox_json_extras_config_contexts_list.go index 8d261abd5..af34dd5d6 100644 --- a/netbox/json/data_netbox_json_extras_config_contexts_list.go +++ b/netbox/json/data_netbox_json_extras_config_contexts_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasConfigContextsList() *schema.Resource { ReadContext: dataNetboxJSONExtrasConfigContextsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasConfigContextsListRead(ctx context.Context, d *schema.R limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasConfigContextsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_content_types_list.go b/netbox/json/data_netbox_json_extras_content_types_list.go index 07a1cee74..39e280ee0 100644 --- a/netbox/json/data_netbox_json_extras_content_types_list.go +++ b/netbox/json/data_netbox_json_extras_content_types_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasContentTypesList() *schema.Resource { ReadContext: dataNetboxJSONExtrasContentTypesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasContentTypesListRead(ctx context.Context, d *schema.Res limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasContentTypesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_custom_fields_list.go b/netbox/json/data_netbox_json_extras_custom_fields_list.go index c32e17b39..013ec8ab7 100644 --- a/netbox/json/data_netbox_json_extras_custom_fields_list.go +++ b/netbox/json/data_netbox_json_extras_custom_fields_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasCustomFieldsList() *schema.Resource { ReadContext: dataNetboxJSONExtrasCustomFieldsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasCustomFieldsListRead(ctx context.Context, d *schema.Res limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasCustomFieldsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_custom_links_list.go b/netbox/json/data_netbox_json_extras_custom_links_list.go index 9c624c20b..bad4e7afc 100644 --- a/netbox/json/data_netbox_json_extras_custom_links_list.go +++ b/netbox/json/data_netbox_json_extras_custom_links_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasCustomLinksList() *schema.Resource { ReadContext: dataNetboxJSONExtrasCustomLinksListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasCustomLinksListRead(ctx context.Context, d *schema.Reso limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasCustomLinksList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_export_templates_list.go b/netbox/json/data_netbox_json_extras_export_templates_list.go index 5debb0501..edbbc612a 100644 --- a/netbox/json/data_netbox_json_extras_export_templates_list.go +++ b/netbox/json/data_netbox_json_extras_export_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasExportTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONExtrasExportTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasExportTemplatesListRead(ctx context.Context, d *schema. limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasExportTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_image_attachments_list.go b/netbox/json/data_netbox_json_extras_image_attachments_list.go index c5d4c7acb..9ee18fde8 100644 --- a/netbox/json/data_netbox_json_extras_image_attachments_list.go +++ b/netbox/json/data_netbox_json_extras_image_attachments_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasImageAttachmentsList() *schema.Resource { ReadContext: dataNetboxJSONExtrasImageAttachmentsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasImageAttachmentsListRead(ctx context.Context, d *schema limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasImageAttachmentsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_job_results_list.go b/netbox/json/data_netbox_json_extras_job_results_list.go index b627240d2..93a1616d7 100644 --- a/netbox/json/data_netbox_json_extras_job_results_list.go +++ b/netbox/json/data_netbox_json_extras_job_results_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasJobResultsList() *schema.Resource { ReadContext: dataNetboxJSONExtrasJobResultsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasJobResultsListRead(ctx context.Context, d *schema.Resou limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasJobResultsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_journal_entries_list.go b/netbox/json/data_netbox_json_extras_journal_entries_list.go index 2a820f997..94bf06fd8 100644 --- a/netbox/json/data_netbox_json_extras_journal_entries_list.go +++ b/netbox/json/data_netbox_json_extras_journal_entries_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasJournalEntriesList() *schema.Resource { ReadContext: dataNetboxJSONExtrasJournalEntriesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasJournalEntriesListRead(ctx context.Context, d *schema.R limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasJournalEntriesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_object_changes_list.go b/netbox/json/data_netbox_json_extras_object_changes_list.go index 285505dba..e8db39cf5 100644 --- a/netbox/json/data_netbox_json_extras_object_changes_list.go +++ b/netbox/json/data_netbox_json_extras_object_changes_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasObjectChangesList() *schema.Resource { ReadContext: dataNetboxJSONExtrasObjectChangesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasObjectChangesListRead(ctx context.Context, d *schema.Re limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasObjectChangesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_tags_list.go b/netbox/json/data_netbox_json_extras_tags_list.go index fbbdf50aa..7855eab36 100644 --- a/netbox/json/data_netbox_json_extras_tags_list.go +++ b/netbox/json/data_netbox_json_extras_tags_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasTagsList() *schema.Resource { ReadContext: dataNetboxJSONExtrasTagsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasTagsListRead(ctx context.Context, d *schema.ResourceDat limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasTagsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_extras_webhooks_list.go b/netbox/json/data_netbox_json_extras_webhooks_list.go index c3ccd2226..398a32ddb 100644 --- a/netbox/json/data_netbox_json_extras_webhooks_list.go +++ b/netbox/json/data_netbox_json_extras_webhooks_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/extras" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONExtrasWebhooksList() *schema.Resource { ReadContext: dataNetboxJSONExtrasWebhooksListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONExtrasWebhooksListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Extras.ExtrasWebhooksList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_aggregates_list.go b/netbox/json/data_netbox_json_ipam_aggregates_list.go index c4e9e1448..c38b99098 100644 --- a/netbox/json/data_netbox_json_ipam_aggregates_list.go +++ b/netbox/json/data_netbox_json_ipam_aggregates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamAggregatesList() *schema.Resource { ReadContext: dataNetboxJSONIpamAggregatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamAggregatesListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamAggregatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_asns_list.go b/netbox/json/data_netbox_json_ipam_asns_list.go index 40de40361..aad564b24 100644 --- a/netbox/json/data_netbox_json_ipam_asns_list.go +++ b/netbox/json/data_netbox_json_ipam_asns_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamAsnsList() *schema.Resource { ReadContext: dataNetboxJSONIpamAsnsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamAsnsListRead(ctx context.Context, d *schema.ResourceData, limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamAsnsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_fhrp_group_assignments_list.go b/netbox/json/data_netbox_json_ipam_fhrp_group_assignments_list.go index d02b505c7..6a9dfaa25 100644 --- a/netbox/json/data_netbox_json_ipam_fhrp_group_assignments_list.go +++ b/netbox/json/data_netbox_json_ipam_fhrp_group_assignments_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamFhrpGroupAssignmentsList() *schema.Resource { ReadContext: dataNetboxJSONIpamFhrpGroupAssignmentsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamFhrpGroupAssignmentsListRead(ctx context.Context, d *sche limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamFhrpGroupAssignmentsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_fhrp_groups_list.go b/netbox/json/data_netbox_json_ipam_fhrp_groups_list.go index da5e2010b..dc76df1a0 100644 --- a/netbox/json/data_netbox_json_ipam_fhrp_groups_list.go +++ b/netbox/json/data_netbox_json_ipam_fhrp_groups_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamFhrpGroupsList() *schema.Resource { ReadContext: dataNetboxJSONIpamFhrpGroupsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamFhrpGroupsListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamFhrpGroupsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_ip_addresses_list.go b/netbox/json/data_netbox_json_ipam_ip_addresses_list.go index 39c64e807..6ff44183d 100644 --- a/netbox/json/data_netbox_json_ipam_ip_addresses_list.go +++ b/netbox/json/data_netbox_json_ipam_ip_addresses_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamIPAddressesList() *schema.Resource { ReadContext: dataNetboxJSONIpamIPAddressesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamIPAddressesListRead(ctx context.Context, d *schema.Resour limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamIPAddressesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_ip_ranges_list.go b/netbox/json/data_netbox_json_ipam_ip_ranges_list.go index 7975e83f9..91d345293 100644 --- a/netbox/json/data_netbox_json_ipam_ip_ranges_list.go +++ b/netbox/json/data_netbox_json_ipam_ip_ranges_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamIPRangesList() *schema.Resource { ReadContext: dataNetboxJSONIpamIPRangesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamIPRangesListRead(ctx context.Context, d *schema.ResourceD limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamIPRangesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_l2vpn_terminations_list.go b/netbox/json/data_netbox_json_ipam_l2vpn_terminations_list.go new file mode 100644 index 000000000..650991f8a --- /dev/null +++ b/netbox/json/data_netbox_json_ipam_l2vpn_terminations_list.go @@ -0,0 +1,118 @@ +// Code generated by util/generateJsonDatasources; DO NOT EDIT. +package json + +import ( + "context" + "encoding/json" + "reflect" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + netboxclient "github.com/smutel/go-netbox/v3/netbox/client" + "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" +) + +// This file was generated by the util/generateJsonDatasources. +// Editing this file might prove futile when you re-run the util/generateJsonDatasources command + +func DataNetboxJSONIpamL2vpnTerminationsList() *schema.Resource { + return &schema.Resource{ + Description: "Get json output from the ipam_l2vpn_terminations_list Netbox endpoint.", + ReadContext: dataNetboxJSONIpamL2vpnTerminationsListRead, + + Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, + "limit": { + Type: schema.TypeInt, + Optional: true, + Default: 0, + Description: "The max number of returned results. If 0 is specified, all records will be returned.", + }, + "json": { + Type: schema.TypeString, + Computed: true, + Description: "JSON output of the list of objects for this Netbox endpoint.", + }, + }, + } +} + +func dataNetboxJSONIpamL2vpnTerminationsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*netboxclient.NetBoxAPI) + + params := ipam.NewIpamL2vpnTerminationsListParams() + limit := int64(d.Get("limit").(int)) + params.Limit = &limit + + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + + list, err := client.Ipam.IpamL2vpnTerminationsList(params, nil) + if err != nil { + return diag.FromErr(err) + } + + 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.IpamL2vpnTerminationsList(params, nil) + if err != nil { + return diag.FromErr(err) + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) + + if err = d.Set("json", string(j)); err != nil { + return diag.FromErr(err) + } + d.SetId("NetboxJSONIpamL2vpnTerminationsList") + + return nil +} diff --git a/netbox/json/data_netbox_json_ipam_l2vpns_list.go b/netbox/json/data_netbox_json_ipam_l2vpns_list.go new file mode 100644 index 000000000..70dd9e406 --- /dev/null +++ b/netbox/json/data_netbox_json_ipam_l2vpns_list.go @@ -0,0 +1,118 @@ +// Code generated by util/generateJsonDatasources; DO NOT EDIT. +package json + +import ( + "context" + "encoding/json" + "reflect" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + netboxclient "github.com/smutel/go-netbox/v3/netbox/client" + "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" +) + +// This file was generated by the util/generateJsonDatasources. +// Editing this file might prove futile when you re-run the util/generateJsonDatasources command + +func DataNetboxJSONIpamL2vpnsList() *schema.Resource { + return &schema.Resource{ + Description: "Get json output from the ipam_l2vpns_list Netbox endpoint.", + ReadContext: dataNetboxJSONIpamL2vpnsListRead, + + Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, + "limit": { + Type: schema.TypeInt, + Optional: true, + Default: 0, + Description: "The max number of returned results. If 0 is specified, all records will be returned.", + }, + "json": { + Type: schema.TypeString, + Computed: true, + Description: "JSON output of the list of objects for this Netbox endpoint.", + }, + }, + } +} + +func dataNetboxJSONIpamL2vpnsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*netboxclient.NetBoxAPI) + + params := ipam.NewIpamL2vpnsListParams() + limit := int64(d.Get("limit").(int)) + params.Limit = &limit + + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + + list, err := client.Ipam.IpamL2vpnsList(params, nil) + if err != nil { + return diag.FromErr(err) + } + + 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.IpamL2vpnsList(params, nil) + if err != nil { + return diag.FromErr(err) + } + tmp = append(tmp, list.Payload.Results...) + } + + j, _ := json.Marshal(tmp) + + if err = d.Set("json", string(j)); err != nil { + return diag.FromErr(err) + } + d.SetId("NetboxJSONIpamL2vpnsList") + + return nil +} diff --git a/netbox/json/data_netbox_json_ipam_prefixes_list.go b/netbox/json/data_netbox_json_ipam_prefixes_list.go index 8e46f1e74..83437ab92 100644 --- a/netbox/json/data_netbox_json_ipam_prefixes_list.go +++ b/netbox/json/data_netbox_json_ipam_prefixes_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamPrefixesList() *schema.Resource { ReadContext: dataNetboxJSONIpamPrefixesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamPrefixesListRead(ctx context.Context, d *schema.ResourceD limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamPrefixesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_rirs_list.go b/netbox/json/data_netbox_json_ipam_rirs_list.go index e600a6b74..e870361b3 100644 --- a/netbox/json/data_netbox_json_ipam_rirs_list.go +++ b/netbox/json/data_netbox_json_ipam_rirs_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamRirsList() *schema.Resource { ReadContext: dataNetboxJSONIpamRirsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamRirsListRead(ctx context.Context, d *schema.ResourceData, limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamRirsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_roles_list.go b/netbox/json/data_netbox_json_ipam_roles_list.go index 7fea1df86..42fc7119f 100644 --- a/netbox/json/data_netbox_json_ipam_roles_list.go +++ b/netbox/json/data_netbox_json_ipam_roles_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamRolesList() *schema.Resource { ReadContext: dataNetboxJSONIpamRolesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamRolesListRead(ctx context.Context, d *schema.ResourceData limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamRolesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_route_targets_list.go b/netbox/json/data_netbox_json_ipam_route_targets_list.go index cf099e415..2279db14a 100644 --- a/netbox/json/data_netbox_json_ipam_route_targets_list.go +++ b/netbox/json/data_netbox_json_ipam_route_targets_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamRouteTargetsList() *schema.Resource { ReadContext: dataNetboxJSONIpamRouteTargetsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamRouteTargetsListRead(ctx context.Context, d *schema.Resou limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamRouteTargetsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_service_templates_list.go b/netbox/json/data_netbox_json_ipam_service_templates_list.go index 7541b5666..ac4c41d9e 100644 --- a/netbox/json/data_netbox_json_ipam_service_templates_list.go +++ b/netbox/json/data_netbox_json_ipam_service_templates_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamServiceTemplatesList() *schema.Resource { ReadContext: dataNetboxJSONIpamServiceTemplatesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamServiceTemplatesListRead(ctx context.Context, d *schema.R limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamServiceTemplatesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_services_list.go b/netbox/json/data_netbox_json_ipam_services_list.go index 3ba4e8aae..37bbb2730 100644 --- a/netbox/json/data_netbox_json_ipam_services_list.go +++ b/netbox/json/data_netbox_json_ipam_services_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamServicesList() *schema.Resource { ReadContext: dataNetboxJSONIpamServicesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamServicesListRead(ctx context.Context, d *schema.ResourceD limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamServicesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_vlan_groups_list.go b/netbox/json/data_netbox_json_ipam_vlan_groups_list.go index 627a145be..ec5ddd01b 100644 --- a/netbox/json/data_netbox_json_ipam_vlan_groups_list.go +++ b/netbox/json/data_netbox_json_ipam_vlan_groups_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamVlanGroupsList() *schema.Resource { ReadContext: dataNetboxJSONIpamVlanGroupsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamVlanGroupsListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamVlanGroupsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_vlans_list.go b/netbox/json/data_netbox_json_ipam_vlans_list.go index 3186716f9..0c8cd7ae8 100644 --- a/netbox/json/data_netbox_json_ipam_vlans_list.go +++ b/netbox/json/data_netbox_json_ipam_vlans_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamVlansList() *schema.Resource { ReadContext: dataNetboxJSONIpamVlansListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamVlansListRead(ctx context.Context, d *schema.ResourceData limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamVlansList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_ipam_vrfs_list.go b/netbox/json/data_netbox_json_ipam_vrfs_list.go index 2ca923e54..00aa1768a 100644 --- a/netbox/json/data_netbox_json_ipam_vrfs_list.go +++ b/netbox/json/data_netbox_json_ipam_vrfs_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/ipam" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONIpamVrfsList() *schema.Resource { ReadContext: dataNetboxJSONIpamVrfsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONIpamVrfsListRead(ctx context.Context, d *schema.ResourceData, limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Ipam.IpamVrfsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_tenancy_contact_assignments_list.go b/netbox/json/data_netbox_json_tenancy_contact_assignments_list.go index 253fa7af5..9a8776d55 100644 --- a/netbox/json/data_netbox_json_tenancy_contact_assignments_list.go +++ b/netbox/json/data_netbox_json_tenancy_contact_assignments_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/tenancy" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONTenancyContactAssignmentsList() *schema.Resource { ReadContext: dataNetboxJSONTenancyContactAssignmentsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONTenancyContactAssignmentsListRead(ctx context.Context, d *sch limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Tenancy.TenancyContactAssignmentsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_tenancy_contact_groups_list.go b/netbox/json/data_netbox_json_tenancy_contact_groups_list.go index 8f082bf95..28f332e9e 100644 --- a/netbox/json/data_netbox_json_tenancy_contact_groups_list.go +++ b/netbox/json/data_netbox_json_tenancy_contact_groups_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/tenancy" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONTenancyContactGroupsList() *schema.Resource { ReadContext: dataNetboxJSONTenancyContactGroupsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONTenancyContactGroupsListRead(ctx context.Context, d *schema.R limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Tenancy.TenancyContactGroupsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_tenancy_contact_roles_list.go b/netbox/json/data_netbox_json_tenancy_contact_roles_list.go index 839f94bff..cee0331f5 100644 --- a/netbox/json/data_netbox_json_tenancy_contact_roles_list.go +++ b/netbox/json/data_netbox_json_tenancy_contact_roles_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/tenancy" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONTenancyContactRolesList() *schema.Resource { ReadContext: dataNetboxJSONTenancyContactRolesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONTenancyContactRolesListRead(ctx context.Context, d *schema.Re limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Tenancy.TenancyContactRolesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_tenancy_contacts_list.go b/netbox/json/data_netbox_json_tenancy_contacts_list.go index 2f4b04d0b..7cf151865 100644 --- a/netbox/json/data_netbox_json_tenancy_contacts_list.go +++ b/netbox/json/data_netbox_json_tenancy_contacts_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/tenancy" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONTenancyContactsList() *schema.Resource { ReadContext: dataNetboxJSONTenancyContactsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONTenancyContactsListRead(ctx context.Context, d *schema.Resour limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Tenancy.TenancyContactsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_tenancy_tenant_groups_list.go b/netbox/json/data_netbox_json_tenancy_tenant_groups_list.go index f809a87f2..77f5a21f7 100644 --- a/netbox/json/data_netbox_json_tenancy_tenant_groups_list.go +++ b/netbox/json/data_netbox_json_tenancy_tenant_groups_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/tenancy" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONTenancyTenantGroupsList() *schema.Resource { ReadContext: dataNetboxJSONTenancyTenantGroupsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONTenancyTenantGroupsListRead(ctx context.Context, d *schema.Re limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Tenancy.TenancyTenantGroupsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_tenancy_tenants_list.go b/netbox/json/data_netbox_json_tenancy_tenants_list.go index 7b6cc8a47..33c192268 100644 --- a/netbox/json/data_netbox_json_tenancy_tenants_list.go +++ b/netbox/json/data_netbox_json_tenancy_tenants_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/tenancy" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONTenancyTenantsList() *schema.Resource { ReadContext: dataNetboxJSONTenancyTenantsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONTenancyTenantsListRead(ctx context.Context, d *schema.Resourc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Tenancy.TenancyTenantsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_users_groups_list.go b/netbox/json/data_netbox_json_users_groups_list.go index 30ee2f3e3..443f73b6f 100644 --- a/netbox/json/data_netbox_json_users_groups_list.go +++ b/netbox/json/data_netbox_json_users_groups_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/users" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONUsersGroupsList() *schema.Resource { ReadContext: dataNetboxJSONUsersGroupsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONUsersGroupsListRead(ctx context.Context, d *schema.ResourceDa limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Users.UsersGroupsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_users_permissions_list.go b/netbox/json/data_netbox_json_users_permissions_list.go index 32a49004e..0847a9b29 100644 --- a/netbox/json/data_netbox_json_users_permissions_list.go +++ b/netbox/json/data_netbox_json_users_permissions_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/users" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONUsersPermissionsList() *schema.Resource { ReadContext: dataNetboxJSONUsersPermissionsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONUsersPermissionsListRead(ctx context.Context, d *schema.Resou limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Users.UsersPermissionsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_users_tokens_list.go b/netbox/json/data_netbox_json_users_tokens_list.go index 67bf3b046..316db9ea5 100644 --- a/netbox/json/data_netbox_json_users_tokens_list.go +++ b/netbox/json/data_netbox_json_users_tokens_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/users" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONUsersTokensList() *schema.Resource { ReadContext: dataNetboxJSONUsersTokensListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONUsersTokensListRead(ctx context.Context, d *schema.ResourceDa limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Users.UsersTokensList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_users_users_list.go b/netbox/json/data_netbox_json_users_users_list.go index e4a8334aa..bef2dce42 100644 --- a/netbox/json/data_netbox_json_users_users_list.go +++ b/netbox/json/data_netbox_json_users_users_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/users" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONUsersUsersList() *schema.Resource { ReadContext: dataNetboxJSONUsersUsersListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONUsersUsersListRead(ctx context.Context, d *schema.ResourceDat limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Users.UsersUsersList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_virtualization_cluster_groups_list.go b/netbox/json/data_netbox_json_virtualization_cluster_groups_list.go index 882472799..a34536fd8 100644 --- a/netbox/json/data_netbox_json_virtualization_cluster_groups_list.go +++ b/netbox/json/data_netbox_json_virtualization_cluster_groups_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/virtualization" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONVirtualizationClusterGroupsList() *schema.Resource { ReadContext: dataNetboxJSONVirtualizationClusterGroupsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONVirtualizationClusterGroupsListRead(ctx context.Context, d *s limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Virtualization.VirtualizationClusterGroupsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_virtualization_cluster_types_list.go b/netbox/json/data_netbox_json_virtualization_cluster_types_list.go index a88f6d5f7..137e6181b 100644 --- a/netbox/json/data_netbox_json_virtualization_cluster_types_list.go +++ b/netbox/json/data_netbox_json_virtualization_cluster_types_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/virtualization" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONVirtualizationClusterTypesList() *schema.Resource { ReadContext: dataNetboxJSONVirtualizationClusterTypesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONVirtualizationClusterTypesListRead(ctx context.Context, d *sc limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Virtualization.VirtualizationClusterTypesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_virtualization_clusters_list.go b/netbox/json/data_netbox_json_virtualization_clusters_list.go index af7e6fcaa..1d12982cf 100644 --- a/netbox/json/data_netbox_json_virtualization_clusters_list.go +++ b/netbox/json/data_netbox_json_virtualization_clusters_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/virtualization" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONVirtualizationClustersList() *schema.Resource { ReadContext: dataNetboxJSONVirtualizationClustersListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONVirtualizationClustersListRead(ctx context.Context, d *schema limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Virtualization.VirtualizationClustersList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_virtualization_interfaces_list.go b/netbox/json/data_netbox_json_virtualization_interfaces_list.go index 88af89edb..ed77980df 100644 --- a/netbox/json/data_netbox_json_virtualization_interfaces_list.go +++ b/netbox/json/data_netbox_json_virtualization_interfaces_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/virtualization" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONVirtualizationInterfacesList() *schema.Resource { ReadContext: dataNetboxJSONVirtualizationInterfacesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONVirtualizationInterfacesListRead(ctx context.Context, d *sche limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Virtualization.VirtualizationInterfacesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_virtualization_virtual_machines_list.go b/netbox/json/data_netbox_json_virtualization_virtual_machines_list.go index 5aceeebf2..7ab551910 100644 --- a/netbox/json/data_netbox_json_virtualization_virtual_machines_list.go +++ b/netbox/json/data_netbox_json_virtualization_virtual_machines_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/virtualization" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONVirtualizationVirtualMachinesList() *schema.Resource { ReadContext: dataNetboxJSONVirtualizationVirtualMachinesListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONVirtualizationVirtualMachinesListRead(ctx context.Context, d limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Virtualization.VirtualizationVirtualMachinesList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_wireless_wireless_lan_groups_list.go b/netbox/json/data_netbox_json_wireless_wireless_lan_groups_list.go index 9629df985..c8c0eddb7 100644 --- a/netbox/json/data_netbox_json_wireless_wireless_lan_groups_list.go +++ b/netbox/json/data_netbox_json_wireless_wireless_lan_groups_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/wireless" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONWirelessWirelessLanGroupsList() *schema.Resource { ReadContext: dataNetboxJSONWirelessWirelessLanGroupsListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONWirelessWirelessLanGroupsListRead(ctx context.Context, d *sch limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Wireless.WirelessWirelessLanGroupsList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_wireless_wireless_lans_list.go b/netbox/json/data_netbox_json_wireless_wireless_lans_list.go index 44ff32159..a0a0e2ac7 100644 --- a/netbox/json/data_netbox_json_wireless_wireless_lans_list.go +++ b/netbox/json/data_netbox_json_wireless_wireless_lans_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/wireless" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONWirelessWirelessLansList() *schema.Resource { ReadContext: dataNetboxJSONWirelessWirelessLansListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONWirelessWirelessLansListRead(ctx context.Context, d *schema.R limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Wireless.WirelessWirelessLansList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/json/data_netbox_json_wireless_wireless_links_list.go b/netbox/json/data_netbox_json_wireless_wireless_links_list.go index e6ba5523d..93b189b57 100644 --- a/netbox/json/data_netbox_json_wireless_wireless_links_list.go +++ b/netbox/json/data_netbox_json_wireless_wireless_links_list.go @@ -4,11 +4,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/wireless" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -20,6 +22,25 @@ func DataNetboxJSONWirelessWirelessLinksList() *schema.Resource { ReadContext: dataNetboxJSONWirelessWirelessLinksListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -42,6 +63,22 @@ func dataNetboxJSONWirelessWirelessLinksListRead(ctx context.Context, d *schema. limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.Wireless.WirelessWirelessLinksList(params, nil) if err != nil { return diag.FromErr(err) diff --git a/netbox/provider.go b/netbox/provider.go index b61bd16ab..50ffb2dfc 100644 --- a/netbox/provider.go +++ b/netbox/provider.go @@ -64,6 +64,7 @@ func Provider() *schema.Provider { "netbox_json_circuits_provider_networks_list": json.DataNetboxJSONCircuitsProviderNetworksList(), "netbox_json_circuits_providers_list": json.DataNetboxJSONCircuitsProvidersList(), "netbox_json_dcim_cables_list": json.DataNetboxJSONDcimCablesList(), + "netbox_json_dcim_cable_terminations_list": json.DataNetboxJSONDcimCableTerminationsList(), "netbox_json_dcim_console_ports_list": json.DataNetboxJSONDcimConsolePortsList(), "netbox_json_dcim_console_port_templates_list": json.DataNetboxJSONDcimConsolePortTemplatesList(), "netbox_json_dcim_console_server_ports_list": json.DataNetboxJSONDcimConsoleServerPortsList(), @@ -119,6 +120,8 @@ func Provider() *schema.Provider { "netbox_json_ipam_fhrp_groups_list": json.DataNetboxJSONIpamFhrpGroupsList(), "netbox_json_ipam_ip_addresses_list": json.DataNetboxJSONIpamIPAddressesList(), "netbox_json_ipam_ip_ranges_list": json.DataNetboxJSONIpamIPRangesList(), + "netbox_json_ipam_l2vpns_list": json.DataNetboxJSONIpamL2vpnsList(), + "netbox_json_ipam_l2vpn_terminations_list": json.DataNetboxJSONIpamL2vpnTerminationsList(), "netbox_json_ipam_prefixes_list": json.DataNetboxJSONIpamPrefixesList(), "netbox_json_ipam_rirs_list": json.DataNetboxJSONIpamRirsList(), "netbox_json_ipam_roles_list": json.DataNetboxJSONIpamRolesList(), diff --git a/utils/generateJsonDatasources b/utils/generateJsonDatasources index 95ad2b9b7..dc4dd0687 100755 --- a/utils/generateJsonDatasources +++ b/utils/generateJsonDatasources @@ -87,11 +87,13 @@ package json import ( "context" "encoding/json" + "reflect" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" netboxclient "github.com/smutel/go-netbox/v3/netbox/client" "github.com/smutel/go-netbox/v3/netbox/client/${SECTION,}" + "github.com/smutel/terraform-provider-netbox/v6/netbox/internal/util" ) // This file was generated by the util/generateJsonDatasources. @@ -103,6 +105,25 @@ func DataNetboxJSON${SECTION}${ITEM}List() *schema.Resource { ReadContext: dataNetboxJSON${SECTION}${ITEM}ListRead, Schema: map[string]*schema.Schema{ + "filter": { + Type: schema.TypeSet, + Optional: true, + Description: "Filter the records returned by the query.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the field to use for filtering.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "Value of the field to use for filtering.", + }, + }, + }, + }, "limit": { Type: schema.TypeInt, Optional: true, @@ -125,6 +146,22 @@ func dataNetboxJSON${SECTION}${ITEM}ListRead(ctx context.Context, d *schema.Reso limit := int64(d.Get("limit").(int)) params.Limit = &limit + if filter, ok := d.GetOk("filter"); ok { + var filterParams = filter.(*schema.Set) + for _, f := range filterParams.List() { + k := f.(map[string]interface{})["name"] + v := f.(map[string]interface{})["value"] + kString := k.(string) + vString := v.(string) + field := reflect.ValueOf(params).Elem().FieldByName(util.FieldNameToStructName(kString)) + if field != (reflect.Value{}) { + field.Set(reflect.ValueOf(&vString)) + } else { + return diag.Errorf("Field %s does not exist in schema.", kString) + } + } + } + list, err := client.${SECTION}.${SECTION}${ITEM}List(params, nil) if err != nil { return diag.FromErr(err)