From 75b9e3f97b2c8dfdb756076397d0910b20ac39df Mon Sep 17 00:00:00 2001 From: yoo <1328109+yoo@users.noreply.github.com> Date: Mon, 20 May 2024 15:16:57 +0200 Subject: [PATCH] feat: introduce new api client based on netbox-community/go-netbox The NetBox API client setup is moved to netbox/client to keep the provider setup code clean. The `Config` struct is passed to the provider functions containing both the legacy- and new API client. The version check in the provider setup is the only API call move to the new client. The only thing changed in the existing resources is the type assertion to access the legacy client. --- go.mod | 3 +- go.sum | 4 +- netbox/{ => client}/client.go | 49 +++++++++-- netbox/{ => client}/client_test.go | 60 +++++++++---- netbox/data_source_netbox_asn.go | 3 +- netbox/data_source_netbox_asns.go | 3 +- netbox/data_source_netbox_available_prefix.go | 3 +- netbox/data_source_netbox_cluster.go | 3 +- netbox/data_source_netbox_cluster_group.go | 3 +- netbox/data_source_netbox_cluster_type.go | 3 +- netbox/data_source_netbox_contact.go | 3 +- netbox/data_source_netbox_contact_group.go | 3 +- netbox/data_source_netbox_contact_role.go | 3 +- .../data_source_netbox_device_interfaces.go | 3 +- netbox/data_source_netbox_device_role.go | 3 +- netbox/data_source_netbox_device_type.go | 3 +- netbox/data_source_netbox_devices.go | 10 +-- netbox/data_source_netbox_interfaces.go | 3 +- netbox/data_source_netbox_ip_addresses.go | 3 +- netbox/data_source_netbox_ip_range.go | 3 +- netbox/data_source_netbox_ipam_role.go | 3 +- netbox/data_source_netbox_location.go | 3 +- netbox/data_source_netbox_locations.go | 3 +- netbox/data_source_netbox_platform.go | 3 +- netbox/data_source_netbox_prefix.go | 3 +- netbox/data_source_netbox_prefixes.go | 3 +- netbox/data_source_netbox_rack_role.go | 3 +- netbox/data_source_netbox_racks.go | 3 +- netbox/data_source_netbox_region.go | 3 +- netbox/data_source_netbox_route_target.go | 3 +- netbox/data_source_netbox_site.go | 3 +- netbox/data_source_netbox_site_group.go | 3 +- netbox/data_source_netbox_tag.go | 3 +- netbox/data_source_netbox_tags.go | 3 +- netbox/data_source_netbox_tenant.go | 3 +- netbox/data_source_netbox_tenant_group.go | 3 +- netbox/data_source_netbox_tenants.go | 3 +- netbox/data_source_netbox_virtual_machines.go | 3 +- netbox/data_source_netbox_vlan.go | 3 +- netbox/data_source_netbox_vlan_group.go | 3 +- netbox/data_source_netbox_vlans.go | 3 +- netbox/data_source_netbox_vrf.go | 3 +- netbox/data_source_netbox_vrfs.go | 3 +- netbox/provider.go | 84 +++++++++++-------- netbox/provider_test.go | 24 ++++-- netbox/resource_netbox_aggregate.go | 9 +- netbox/resource_netbox_aggregate_test.go | 3 +- netbox/resource_netbox_asn.go | 9 +- netbox/resource_netbox_asn_test.go | 3 +- .../resource_netbox_available_ip_address.go | 9 +- ...source_netbox_available_ip_address_test.go | 3 +- netbox/resource_netbox_available_prefix.go | 3 +- .../resource_netbox_available_prefix_test.go | 3 +- netbox/resource_netbox_cable.go | 9 +- netbox/resource_netbox_cable_test.go | 5 +- netbox/resource_netbox_circuit.go | 9 +- netbox/resource_netbox_circuit_provider.go | 9 +- .../resource_netbox_circuit_provider_test.go | 3 +- netbox/resource_netbox_circuit_termination.go | 9 +- ...esource_netbox_circuit_termination_test.go | 3 +- netbox/resource_netbox_circuit_test.go | 3 +- netbox/resource_netbox_circuit_type.go | 9 +- netbox/resource_netbox_circuit_type_test.go | 3 +- netbox/resource_netbox_cluster.go | 9 +- netbox/resource_netbox_cluster_group.go | 9 +- netbox/resource_netbox_cluster_group_test.go | 3 +- netbox/resource_netbox_cluster_test.go | 3 +- netbox/resource_netbox_cluster_type.go | 9 +- netbox/resource_netbox_cluster_type_test.go | 3 +- netbox/resource_netbox_contact.go | 9 +- netbox/resource_netbox_contact_assignment.go | 9 +- ...resource_netbox_contact_assignment_test.go | 3 +- netbox/resource_netbox_contact_group.go | 9 +- netbox/resource_netbox_contact_group_test.go | 3 +- netbox/resource_netbox_contact_role.go | 9 +- netbox/resource_netbox_contact_role_test.go | 3 +- netbox/resource_netbox_contact_test.go | 3 +- netbox/resource_netbox_custom_field.go | 9 +- ...resource_netbox_custom_field_choice_set.go | 9 +- netbox/resource_netbox_device.go | 9 +- netbox/resource_netbox_device_console_port.go | 9 +- ...esource_netbox_device_console_port_test.go | 5 +- ...ource_netbox_device_console_server_port.go | 9 +- ..._netbox_device_console_server_port_test.go | 5 +- netbox/resource_netbox_device_front_port.go | 9 +- .../resource_netbox_device_front_port_test.go | 5 +- netbox/resource_netbox_device_interface.go | 9 +- .../resource_netbox_device_interface_test.go | 5 +- netbox/resource_netbox_device_module_bay.go | 9 +- .../resource_netbox_device_module_bay_test.go | 5 +- netbox/resource_netbox_device_power_feed.go | 9 +- .../resource_netbox_device_power_feed_test.go | 5 +- netbox/resource_netbox_device_power_outlet.go | 9 +- ...esource_netbox_device_power_outlet_test.go | 5 +- netbox/resource_netbox_device_power_port.go | 9 +- .../resource_netbox_device_power_port_test.go | 5 +- netbox/resource_netbox_device_primary_ip.go | 5 +- netbox/resource_netbox_device_rear_port.go | 9 +- .../resource_netbox_device_rear_port_test.go | 5 +- netbox/resource_netbox_device_role.go | 9 +- netbox/resource_netbox_device_role_test.go | 3 +- netbox/resource_netbox_device_test.go | 5 +- netbox/resource_netbox_device_type.go | 9 +- netbox/resource_netbox_device_type_test.go | 3 +- netbox/resource_netbox_event_rule.go | 9 +- netbox/resource_netbox_event_rule_test.go | 5 +- netbox/resource_netbox_group.go | 9 +- netbox/resource_netbox_group_test.go | 3 +- netbox/resource_netbox_interface.go | 9 +- netbox/resource_netbox_interface_test.go | 5 +- netbox/resource_netbox_inventory_item.go | 9 +- netbox/resource_netbox_inventory_item_role.go | 9 +- ...esource_netbox_inventory_item_role_test.go | 5 +- netbox/resource_netbox_inventory_item_test.go | 5 +- netbox/resource_netbox_ip_address.go | 9 +- netbox/resource_netbox_ip_address_test.go | 3 +- netbox/resource_netbox_ip_range.go | 9 +- netbox/resource_netbox_ip_range_test.go | 3 +- netbox/resource_netbox_ipam_role.go | 9 +- netbox/resource_netbox_ipam_role_test.go | 3 +- netbox/resource_netbox_location.go | 9 +- netbox/resource_netbox_location_test.go | 3 +- netbox/resource_netbox_manufacturer.go | 9 +- netbox/resource_netbox_manufacturer_test.go | 3 +- netbox/resource_netbox_module.go | 9 +- netbox/resource_netbox_module_test.go | 5 +- netbox/resource_netbox_module_type.go | 9 +- netbox/resource_netbox_module_type_test.go | 5 +- netbox/resource_netbox_permission.go | 9 +- netbox/resource_netbox_permission_test.go | 3 +- netbox/resource_netbox_platform.go | 9 +- netbox/resource_netbox_platform_test.go | 3 +- netbox/resource_netbox_power_panel.go | 9 +- netbox/resource_netbox_power_panel_test.go | 5 +- netbox/resource_netbox_prefix.go | 9 +- netbox/resource_netbox_prefix_test.go | 3 +- netbox/resource_netbox_primary_ip.go | 5 +- netbox/resource_netbox_rack.go | 9 +- netbox/resource_netbox_rack_reservation.go | 9 +- .../resource_netbox_rack_reservation_test.go | 3 +- netbox/resource_netbox_rack_role.go | 9 +- netbox/resource_netbox_rack_role_test.go | 3 +- netbox/resource_netbox_rack_test.go | 5 +- netbox/resource_netbox_region.go | 9 +- netbox/resource_netbox_region_test.go | 3 +- netbox/resource_netbox_rir.go | 9 +- netbox/resource_netbox_rir_test.go | 3 +- netbox/resource_netbox_route_target.go | 9 +- netbox/resource_netbox_route_target_test.go | 3 +- netbox/resource_netbox_service.go | 9 +- netbox/resource_netbox_service_test.go | 5 +- netbox/resource_netbox_site.go | 9 +- netbox/resource_netbox_site_group.go | 9 +- netbox/resource_netbox_site_group_test.go | 3 +- netbox/resource_netbox_site_test.go | 3 +- netbox/resource_netbox_tag.go | 9 +- netbox/resource_netbox_tag_test.go | 3 +- netbox/resource_netbox_tenant.go | 9 +- netbox/resource_netbox_tenant_group.go | 9 +- netbox/resource_netbox_tenant_group_test.go | 3 +- netbox/resource_netbox_tenant_test.go | 3 +- netbox/resource_netbox_token.go | 9 +- netbox/resource_netbox_token_test.go | 3 +- netbox/resource_netbox_user.go | 9 +- netbox/resource_netbox_user_test.go | 3 +- netbox/resource_netbox_virtual_chassis.go | 8 +- .../resource_netbox_virtual_chassis_test.go | 3 +- netbox/resource_netbox_virtual_disk.go | 9 +- netbox/resource_netbox_virtual_disk_test.go | 3 +- netbox/resource_netbox_virtual_machine.go | 9 +- .../resource_netbox_virtual_machine_test.go | 5 +- netbox/resource_netbox_vlan.go | 9 +- netbox/resource_netbox_vlan_group.go | 9 +- netbox/resource_netbox_vlan_group_test.go | 3 +- netbox/resource_netbox_vlan_test.go | 3 +- netbox/resource_netbox_vpn_tunnel.go | 9 +- netbox/resource_netbox_vpn_tunnel_group.go | 9 +- .../resource_netbox_vpn_tunnel_group_test.go | 3 +- .../resource_netbox_vpn_tunnel_termination.go | 9 +- ...urce_netbox_vpn_tunnel_termination_test.go | 3 +- netbox/resource_netbox_vpn_tunnel_test.go | 3 +- netbox/resource_netbox_vrf.go | 9 +- netbox/resource_netbox_vrf_test.go | 3 +- netbox/resource_netbox_webhook.go | 9 +- netbox/resource_netbox_webhook_test.go | 5 +- tools/tools.go | 1 + 186 files changed, 571 insertions(+), 659 deletions(-) rename netbox/{ => client}/client.go (61%) rename netbox/{ => client}/client_test.go (58%) diff --git a/go.mod b/go.mod index aa5bfed4..1f12c8bd 100644 --- a/go.mod +++ b/go.mod @@ -11,9 +11,9 @@ require ( github.com/go-openapi/strfmt v0.23.0 github.com/goware/urlx v0.3.2 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 + github.com/netbox-community/go-netbox/v3 v3.7.7-0 github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.9.0 - golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 ) require ( @@ -96,6 +96,7 @@ require ( golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.15.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect google.golang.org/grpc v1.61.1 // indirect diff --git a/go.sum b/go.sum index 666d39d5..e87ad2e3 100644 --- a/go.sum +++ b/go.sum @@ -195,6 +195,8 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/netbox-community/go-netbox/v3 v3.7.7-0 h1:LgqVZtPSMKazezJVCrnajTXEHxDl6xlJNpH/UBsHp8U= +github.com/netbox-community/go-netbox/v3 v3.7.7-0/go.mod h1:rk3PBE/6oWvgmFH2dxoD2JyN+lkDWJ0dhNmy6HXBvVs= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= @@ -263,8 +265,6 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 h1:mchzmB1XO2pMaKFRqk/+MV3mgGG96aqaPXaMifQU47w= -golang.org/x/exp v0.0.0-20231108232855-2478ac86f678/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= diff --git a/netbox/client.go b/netbox/client/client.go similarity index 61% rename from netbox/client.go rename to netbox/client/client.go index a176247d..650686e6 100644 --- a/netbox/client.go +++ b/netbox/client/client.go @@ -1,13 +1,15 @@ -package netbox +package client import ( + "crypto/tls" "fmt" "net/http" "time" - netboxclient "github.com/fbreckle/go-netbox/netbox/client" + netboxlegacy "github.com/fbreckle/go-netbox/netbox/client" httptransport "github.com/go-openapi/runtime/client" "github.com/goware/urlx" + netbox "github.com/netbox-community/go-netbox/v3" log "github.com/sirupsen/logrus" ) @@ -28,11 +30,13 @@ type customHeaderTransport struct { headers map[string]interface{} } -// Client does the heavy lifting of establishing a base Open API client to Netbox. -func (cfg *Config) Client() (*netboxclient.NetBoxAPI, error) { +// NewLegacyClient creates a NetBox API client based of github.com/fbreckle/go-netbox. +// It uses the legacy API client, which is based on the OpenAPI 2.0 specification. +// This client is deprecated and will be removed in the future. +func NewLegacyClient(cfg *Config) (*netboxlegacy.NetBoxAPI, error) { log.WithFields(log.Fields{ "server_url": cfg.ServerURL, - }).Debug("Initializing Netbox client") + }).Debug("Initializing Netbox legacy client") if cfg.APIToken == "" { return nil, fmt.Errorf("missing netbox API key") @@ -76,14 +80,45 @@ func (cfg *Config) Client() (*netboxclient.NetBoxAPI, error) { Timeout: time.Second * time.Duration(cfg.RequestTimeout), } - transport := httptransport.NewWithClient(parsedURL.Host, parsedURL.Path+netboxclient.DefaultBasePath, desiredRuntimeClientSchemes, httpClient) + transport := httptransport.NewWithClient(parsedURL.Host, parsedURL.Path+netboxlegacy.DefaultBasePath, desiredRuntimeClientSchemes, httpClient) transport.DefaultAuthentication = httptransport.APIKeyAuth("Authorization", "header", fmt.Sprintf("Token %v", cfg.APIToken)) transport.SetLogger(log.StandardLogger()) - netboxClient := netboxclient.New(transport, nil) + netboxClient := netboxlegacy.New(transport, nil) return netboxClient, nil } +// NewClient creates a NetBox API client based on github.com/netbox-community/go-netbox. +// This client is based on the OpenAPI 3.0 specification. +func NewClient(cfg *Config) (*netbox.APIClient, error) { + log.WithFields(log.Fields{ + "server_url": cfg.ServerURL, + }).Debug("Initializing Netbox client") + if cfg.APIToken == "" { + return nil, fmt.Errorf("missing netbox API key") + } + + headers := map[string]string{} + for k, v := range cfg.Headers { + headers[k] = fmt.Sprintf("%v", v) + } + headers["Authorization"] = fmt.Sprintf("Token %v", cfg.APIToken) + + return netbox.NewAPIClient(&netbox.Configuration{ + Servers: []netbox.ServerConfiguration{{ + URL: cfg.ServerURL, + Description: "NetBox", + }}, + HTTPClient: &http.Client{ + Timeout: time.Second * time.Duration(cfg.RequestTimeout), + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: cfg.AllowInsecureHTTPS}, + }, + }, + DefaultHeader: headers, + }), nil +} + // RoundTrip adds the headers specified in the transport on every request. func (t customHeaderTransport) RoundTrip(r *http.Request) (*http.Response, error) { for key, value := range t.headers { diff --git a/netbox/client_test.go b/netbox/client/client_test.go similarity index 58% rename from netbox/client_test.go rename to netbox/client/client_test.go index 1d0466e3..0b7a0783 100644 --- a/netbox/client_test.go +++ b/netbox/client/client_test.go @@ -1,6 +1,7 @@ -package netbox +package client import ( + "context" "net/http" "net/http/httptest" "testing" @@ -10,56 +11,76 @@ import ( ) func TestValidClientWithAllData(t *testing.T) { - config := Config{ + config := &Config{ APIToken: "07b12b765127747e4afd56cb531b7bf9c61f3c30", ServerURL: "https://localhost:8080", } - client, err := config.Client() + client, err := NewClient(config) assert.NotNil(t, client) assert.NoError(t, err) + + legacyClient, err := NewLegacyClient(config) + assert.NotNil(t, legacyClient) + assert.NoError(t, err) } func TestURLMissingSchemaShouldWork(t *testing.T) { - config := Config{ + config := &Config{ APIToken: "07b12b765127747e4afd56cb531b7bf9c61f3c30", ServerURL: "localhost:8080", } - client, err := config.Client() + client, err := NewClient(config) assert.NotNil(t, client) assert.NoError(t, err) + + legacyClient, err := NewLegacyClient(config) + assert.NotNil(t, legacyClient) + assert.NoError(t, err) } -func TestURLMaleformedUrlShouldFail(t *testing.T) { - config := Config{ +func TestURLMalformedUrlShouldFail(t *testing.T) { + config := &Config{ APIToken: "07b12b765127747e4afd56cb531b7bf9c61f3c30", ServerURL: "xyz:/localhost:8080", } - _, err := config.Client() + _, err := NewClient(config) + assert.Error(t, err) + + _, err = NewLegacyClient(config) assert.Error(t, err) } func TestURLMissingPortShouldWork(t *testing.T) { - config := Config{ + config := &Config{ APIToken: "07b12b765127747e4afd56cb531b7bf9c61f3c30", ServerURL: "http://localhost", } - client, err := config.Client() + client, err := NewClient(config) assert.NotNil(t, client) assert.NoError(t, err) + + legacyClient, err := NewLegacyClient(config) + + assert.NotNil(t, legacyClient) + assert.NoError(t, err) } func TestURLMissingAccessKey(t *testing.T) { - config := Config{ + config := &Config{ APIToken: "", ServerURL: "http://localhost", } - _, err := config.Client() + _, err := NewClient(config) + assert.Error(t, err) + + _, err = NewLegacyClient(config) assert.Error(t, err) + } func TestAdditionalHeadersSet(t *testing.T) { @@ -72,7 +93,7 @@ func TestAdditionalHeadersSet(t *testing.T) { })) defer ts.Close() - config := Config{ + config := &Config{ APIToken: "07b12b765127747e4afd56cb531b7bf9c61f3c30", ServerURL: ts.URL, Headers: map[string]interface{}{ @@ -80,11 +101,18 @@ func TestAdditionalHeadersSet(t *testing.T) { }, } - client, err := config.Client() + client, err := NewClient(config) assert.NoError(t, err) - req := status.NewStatusListParams() - client.Status.StatusList(req, nil) + req := client.StatusAPI.StatusRetrieve(context.Background()) + req.Execute() + + legacyClient, err := NewLegacyClient(config) + assert.NoError(t, err) + + legacyReq := status.NewStatusListParams() + legacyClient.Status.StatusList(legacyReq, nil) + } /* TODO diff --git a/netbox/data_source_netbox_asn.go b/netbox/data_source_netbox_asn.go index bfa38e81..c35adc4d 100644 --- a/netbox/data_source_netbox_asn.go +++ b/netbox/data_source_netbox_asn.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -46,7 +45,7 @@ for more information on available lookup expressions.`, } func dataSourceNetboxAsnRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamAsnsListParams() diff --git a/netbox/data_source_netbox_asns.go b/netbox/data_source_netbox_asns.go index 51a7fd96..5a2534df 100644 --- a/netbox/data_source_netbox_asns.go +++ b/netbox/data_source_netbox_asns.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -64,7 +63,7 @@ func dataSourceNetboxAsns() *schema.Resource { } func dataSourceNetboxAsnsRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamAsnsListParams() diff --git a/netbox/data_source_netbox_available_prefix.go b/netbox/data_source_netbox_available_prefix.go index e3aba81b..9dee4cde 100644 --- a/netbox/data_source_netbox_available_prefix.go +++ b/netbox/data_source_netbox_available_prefix.go @@ -1,7 +1,6 @@ package netbox import ( - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -41,7 +40,7 @@ func dataSourceNetboxAvailablePrefix() *schema.Resource { } func dataSourceNetboxAvailablePrefixRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamPrefixesAvailablePrefixesListParams() diff --git a/netbox/data_source_netbox_cluster.go b/netbox/data_source_netbox_cluster.go index 1752787c..cf6daa8c 100644 --- a/netbox/data_source_netbox_cluster.go +++ b/netbox/data_source_netbox_cluster.go @@ -5,7 +5,6 @@ import ( "fmt" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -63,7 +62,7 @@ func dataSourceNetboxCluster() *schema.Resource { } func dataSourceNetboxClusterRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := virtualization.NewVirtualizationClustersListParams() diff --git a/netbox/data_source_netbox_cluster_group.go b/netbox/data_source_netbox_cluster_group.go index d23886b6..9eb85f7b 100644 --- a/netbox/data_source_netbox_cluster_group.go +++ b/netbox/data_source_netbox_cluster_group.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -27,7 +26,7 @@ func dataSourceNetboxClusterGroup() *schema.Resource { } func dataSourceNetboxClusterGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) params := virtualization.NewVirtualizationClusterGroupsListParams() diff --git a/netbox/data_source_netbox_cluster_type.go b/netbox/data_source_netbox_cluster_type.go index 2cd6dc65..9f24ee80 100644 --- a/netbox/data_source_netbox_cluster_type.go +++ b/netbox/data_source_netbox_cluster_type.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -27,7 +26,7 @@ func dataSourceNetboxClusterType() *schema.Resource { } func dataSourceNetboxClusterTypeRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) params := virtualization.NewVirtualizationClusterTypesListParams() diff --git a/netbox/data_source_netbox_contact.go b/netbox/data_source_netbox_contact.go index 1eeb5f9e..051f9ad7 100644 --- a/netbox/data_source_netbox_contact.go +++ b/netbox/data_source_netbox_contact.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -39,7 +38,7 @@ func dataSourceNetboxContact() *schema.Resource { } func dataSourceNetboxContactRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyContactsListParams() if name, ok := d.Get("name").(string); ok && name != "" { diff --git a/netbox/data_source_netbox_contact_group.go b/netbox/data_source_netbox_contact_group.go index a979be92..396d3f09 100644 --- a/netbox/data_source_netbox_contact_group.go +++ b/netbox/data_source_netbox_contact_group.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +34,7 @@ func dataSourceNetboxContactGroup() *schema.Resource { } func dataSourceNetboxContactGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) params := tenancy.NewTenancyContactGroupsListParams() diff --git a/netbox/data_source_netbox_contact_role.go b/netbox/data_source_netbox_contact_role.go index b73de5c2..2458a945 100644 --- a/netbox/data_source_netbox_contact_role.go +++ b/netbox/data_source_netbox_contact_role.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -31,7 +30,7 @@ func dataSourceNetboxContactRole() *schema.Resource { } func dataSourceNetboxContactRoleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyContactRolesListParams() if name, ok := d.Get("name").(string); ok && name != "" { diff --git a/netbox/data_source_netbox_device_interfaces.go b/netbox/data_source_netbox_device_interfaces.go index a20997ab..ec837b01 100644 --- a/netbox/data_source_netbox_device_interfaces.go +++ b/netbox/data_source_netbox_device_interfaces.go @@ -5,7 +5,6 @@ import ( "fmt" "regexp" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" @@ -136,7 +135,7 @@ func dataSourceNetboxDeviceInterfaces() *schema.Resource { } func dataSourceNetboxDeviceInterfaceRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimInterfacesListParams() diff --git a/netbox/data_source_netbox_device_role.go b/netbox/data_source_netbox_device_role.go index 3efdc232..79d85966 100644 --- a/netbox/data_source_netbox_device_role.go +++ b/netbox/data_source_netbox_device_role.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -32,7 +31,7 @@ func dataSourceNetboxDeviceRole() *schema.Resource { } func dataSourceNetboxDeviceRoleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) params := dcim.NewDcimDeviceRolesListParams() diff --git a/netbox/data_source_netbox_device_type.go b/netbox/data_source_netbox_device_type.go index 9f2e3a92..0860e687 100644 --- a/netbox/data_source_netbox_device_type.go +++ b/netbox/data_source_netbox_device_type.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -47,7 +46,7 @@ func dataSourceNetboxDeviceType() *schema.Resource { } func dataSourceNetboxDeviceTypeRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimDeviceTypesListParams() params.Limit = int64ToPtr(2) diff --git a/netbox/data_source_netbox_devices.go b/netbox/data_source_netbox_devices.go index 13d3463f..8492c10c 100644 --- a/netbox/data_source_netbox_devices.go +++ b/netbox/data_source_netbox_devices.go @@ -5,15 +5,15 @@ package netbox import ( "fmt" - "github.com/fbreckle/go-netbox/netbox/client" + "net" + "regexp" + "strings" + "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "net" - "regexp" - "strings" ) func dataSourceNetboxDevices() *schema.Resource { @@ -148,7 +148,7 @@ func dataSourceNetboxDevices() *schema.Resource { } func dataSourceNetboxDevicesRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimDevicesListParams() diff --git a/netbox/data_source_netbox_interfaces.go b/netbox/data_source_netbox_interfaces.go index b2e0e6c0..61179543 100644 --- a/netbox/data_source_netbox_interfaces.go +++ b/netbox/data_source_netbox_interfaces.go @@ -5,7 +5,6 @@ import ( "fmt" "regexp" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" @@ -143,7 +142,7 @@ func dataSourceNetboxInterfaces() *schema.Resource { } func dataSourceNetboxInterfaceRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := virtualization.NewVirtualizationInterfacesListParams() diff --git a/netbox/data_source_netbox_ip_addresses.go b/netbox/data_source_netbox_ip_addresses.go index f4472434..3aa05c7a 100644 --- a/netbox/data_source_netbox_ip_addresses.go +++ b/netbox/data_source_netbox_ip_addresses.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" @@ -137,7 +136,7 @@ func dataSourceNetboxIPAddresses() *schema.Resource { } func dataSourceNetboxIPAddressesRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamIPAddressesListParams() diff --git a/netbox/data_source_netbox_ip_range.go b/netbox/data_source_netbox_ip_range.go index 1938c4d6..b7597db1 100644 --- a/netbox/data_source_netbox_ip_range.go +++ b/netbox/data_source_netbox_ip_range.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -29,7 +28,7 @@ func dataSourceNetboxIPRange() *schema.Resource { } func dataSourceNetboxIPRangeRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient contains := d.Get("contains").(string) diff --git a/netbox/data_source_netbox_ipam_role.go b/netbox/data_source_netbox_ipam_role.go index 5ef200e8..c14606c3 100644 --- a/netbox/data_source_netbox_ipam_role.go +++ b/netbox/data_source_netbox_ipam_role.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +34,7 @@ func dataSourceNetboxIPAMRole() *schema.Resource { } func dataSourceNetboxIPAMRoleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) diff --git a/netbox/data_source_netbox_location.go b/netbox/data_source_netbox_location.go index a79392b1..681ce291 100644 --- a/netbox/data_source_netbox_location.go +++ b/netbox/data_source_netbox_location.go @@ -5,7 +5,6 @@ import ( "fmt" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -56,7 +55,7 @@ func dataSourceNetboxLocation() *schema.Resource { } func dataSourceNetboxLocationRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimLocationsListParams() params.Limit = int64ToPtr(2) diff --git a/netbox/data_source_netbox_locations.go b/netbox/data_source_netbox_locations.go index 6fe1d9ff..a52f5e9d 100644 --- a/netbox/data_source_netbox_locations.go +++ b/netbox/data_source_netbox_locations.go @@ -4,7 +4,6 @@ import ( "fmt" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -95,7 +94,7 @@ func dataSourceNetboxLocations() *schema.Resource { } func dataSourceNetboxLocationsRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimLocationsListParams() if limitValue, ok := d.GetOk("limit"); ok { diff --git a/netbox/data_source_netbox_platform.go b/netbox/data_source_netbox_platform.go index 9785de34..b8d21c8d 100644 --- a/netbox/data_source_netbox_platform.go +++ b/netbox/data_source_netbox_platform.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -27,7 +26,7 @@ func dataSourceNetboxPlatform() *schema.Resource { } func dataSourceNetboxPlatformRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) params := dcim.NewDcimPlatformsListParams() diff --git a/netbox/data_source_netbox_prefix.go b/netbox/data_source_netbox_prefix.go index ce653b59..f40c987c 100644 --- a/netbox/data_source_netbox_prefix.go +++ b/netbox/data_source_netbox_prefix.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -93,7 +92,7 @@ for more information on available lookup expressions.`, } func dataSourceNetboxPrefixRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamPrefixesListParams() diff --git a/netbox/data_source_netbox_prefixes.go b/netbox/data_source_netbox_prefixes.go index 59326f6e..2becc2bc 100644 --- a/netbox/data_source_netbox_prefixes.go +++ b/netbox/data_source_netbox_prefixes.go @@ -4,7 +4,6 @@ import ( "fmt" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -84,7 +83,7 @@ func dataSourceNetboxPrefixes() *schema.Resource { } func dataSourceNetboxPrefixesRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamPrefixesListParams() diff --git a/netbox/data_source_netbox_rack_role.go b/netbox/data_source_netbox_rack_role.go index 5f0ff322..1744150f 100644 --- a/netbox/data_source_netbox_rack_role.go +++ b/netbox/data_source_netbox_rack_role.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -36,7 +35,7 @@ func dataSourceNetboxRackRole() *schema.Resource { } func dataSourceNetboxRackRoleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) params := dcim.NewDcimRackRolesListParams() diff --git a/netbox/data_source_netbox_racks.go b/netbox/data_source_netbox_racks.go index 9325a7a6..65f9aabd 100644 --- a/netbox/data_source_netbox_racks.go +++ b/netbox/data_source_netbox_racks.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -148,7 +147,7 @@ func dataSourceNetboxRacks() *schema.Resource { } func dataSourceNetboxRacksRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimRacksListParams() diff --git a/netbox/data_source_netbox_region.go b/netbox/data_source_netbox_region.go index 6369eabc..828c6764 100644 --- a/netbox/data_source_netbox_region.go +++ b/netbox/data_source_netbox_region.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -59,7 +58,7 @@ func dataSourceNetboxRegion() *schema.Resource { } func dataSourceNetboxRegionRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimRegionsListParams() diff --git a/netbox/data_source_netbox_route_target.go b/netbox/data_source_netbox_route_target.go index dbaa7233..8dca1196 100644 --- a/netbox/data_source_netbox_route_target.go +++ b/netbox/data_source_netbox_route_target.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -34,7 +33,7 @@ func dataSourceNetboxRouteTarget() *schema.Resource { } func dataSourceNetboxRouteTargetRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) diff --git a/netbox/data_source_netbox_site.go b/netbox/data_source_netbox_site.go index ae14dc28..db40100a 100644 --- a/netbox/data_source_netbox_site.go +++ b/netbox/data_source_netbox_site.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -78,7 +77,7 @@ func dataSourceNetboxSite() *schema.Resource { } func dataSourceNetboxSiteRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimSitesListParams() params.Limit = int64ToPtr(2) diff --git a/netbox/data_source_netbox_site_group.go b/netbox/data_source_netbox_site_group.go index 8d22f4e8..91c27c27 100644 --- a/netbox/data_source_netbox_site_group.go +++ b/netbox/data_source_netbox_site_group.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +34,7 @@ func dataSourceNetboxSiteGroup() *schema.Resource { } func dataSourceNetboxSiteGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimSiteGroupsListParams() if name, ok := d.Get("name").(string); ok && name != "" { diff --git a/netbox/data_source_netbox_tag.go b/netbox/data_source_netbox_tag.go index 86428726..76e7c098 100644 --- a/netbox/data_source_netbox_tag.go +++ b/netbox/data_source_netbox_tag.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -31,7 +30,7 @@ func dataSourceNetboxTag() *schema.Resource { } func dataSourceNetboxTagRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) params := extras.NewExtrasTagsListParams() diff --git a/netbox/data_source_netbox_tags.go b/netbox/data_source_netbox_tags.go index 31d1ea65..fd7d6fe3 100644 --- a/netbox/data_source_netbox_tags.go +++ b/netbox/data_source_netbox_tags.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -71,7 +70,7 @@ func dataSourceNetboxTags() *schema.Resource { } func dataSourceNetboxTagsRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := extras.NewExtrasTagsListParams() diff --git a/netbox/data_source_netbox_tenant.go b/netbox/data_source_netbox_tenant.go index c3c933c4..a841bcfc 100644 --- a/netbox/data_source_netbox_tenant.go +++ b/netbox/data_source_netbox_tenant.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -39,7 +38,7 @@ func dataSourceNetboxTenant() *schema.Resource { } func dataSourceNetboxTenantRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyTenantsListParams() if name, ok := d.Get("name").(string); ok && name != "" { diff --git a/netbox/data_source_netbox_tenant_group.go b/netbox/data_source_netbox_tenant_group.go index d277563a..64e75fc7 100644 --- a/netbox/data_source_netbox_tenant_group.go +++ b/netbox/data_source_netbox_tenant_group.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +34,7 @@ func dataSourceNetboxTenantGroup() *schema.Resource { } func dataSourceNetboxTenantGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) params := tenancy.NewTenancyTenantGroupsListParams() diff --git a/netbox/data_source_netbox_tenants.go b/netbox/data_source_netbox_tenants.go index b2c8d859..25cd39fc 100644 --- a/netbox/data_source_netbox_tenants.go +++ b/netbox/data_source_netbox_tenants.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" @@ -149,7 +148,7 @@ func dataSourceNetboxTenants() *schema.Resource { } func dataSourceNetboxTenantsRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyTenantsListParams() diff --git a/netbox/data_source_netbox_virtual_machines.go b/netbox/data_source_netbox_virtual_machines.go index e5a79696..9ef8855c 100644 --- a/netbox/data_source_netbox_virtual_machines.go +++ b/netbox/data_source_netbox_virtual_machines.go @@ -6,7 +6,6 @@ import ( "fmt" "regexp" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" @@ -152,7 +151,7 @@ func dataSourceNetboxVirtualMachine() *schema.Resource { } func dataSourceNetboxVirtualMachineRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := virtualization.NewVirtualizationVirtualMachinesListParams() diff --git a/netbox/data_source_netbox_vlan.go b/netbox/data_source_netbox_vlan.go index 8478e87f..e5ee0488 100644 --- a/netbox/data_source_netbox_vlan.go +++ b/netbox/data_source_netbox_vlan.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -56,7 +55,7 @@ func dataSourceNetboxVlan() *schema.Resource { } func dataSourceNetboxVlanRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamVlansListParams() params.Limit = int64ToPtr(2) diff --git a/netbox/data_source_netbox_vlan_group.go b/netbox/data_source_netbox_vlan_group.go index 2d63133b..6805bed0 100644 --- a/netbox/data_source_netbox_vlan_group.go +++ b/netbox/data_source_netbox_vlan_group.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -59,7 +58,7 @@ func dataSourceNetboxVlanGroup() *schema.Resource { } func dataSourceNetboxVlanGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamVlanGroupsListParams() params.Limit = int64ToPtr(2) diff --git a/netbox/data_source_netbox_vlans.go b/netbox/data_source_netbox_vlans.go index cc3a0693..44128fd8 100644 --- a/netbox/data_source_netbox_vlans.go +++ b/netbox/data_source_netbox_vlans.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -83,7 +82,7 @@ func dataSourceNetboxVlans() *schema.Resource { } func dataSourceNetboxVlansRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamVlansListParams() diff --git a/netbox/data_source_netbox_vrf.go b/netbox/data_source_netbox_vrf.go index 9c5dbe4e..0e07c6ac 100644 --- a/netbox/data_source_netbox_vrf.go +++ b/netbox/data_source_netbox_vrf.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -27,7 +26,7 @@ func dataSourceNetboxVrf() *schema.Resource { } func dataSourceNetboxVrfRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) params := ipam.NewIpamVrfsListParams() diff --git a/netbox/data_source_netbox_vrfs.go b/netbox/data_source_netbox_vrfs.go index 4d0aa3cc..032ddfe2 100644 --- a/netbox/data_source_netbox_vrfs.go +++ b/netbox/data_source_netbox_vrfs.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -71,7 +70,7 @@ func dataSourceNetboxVrfs() *schema.Resource { } func dataSourceNetboxVrfsRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamVrfsListParams() diff --git a/netbox/provider.go b/netbox/provider.go index 5d9895b4..3b665865 100644 --- a/netbox/provider.go +++ b/netbox/provider.go @@ -4,14 +4,35 @@ import ( "bytes" "context" "fmt" + "slices" "strings" - "github.com/fbreckle/go-netbox/netbox/client/status" + netboxlegacy "github.com/fbreckle/go-netbox/netbox/client" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "golang.org/x/exp/slices" + netbox "github.com/netbox-community/go-netbox/v3" + + "github.com/e-breuninger/terraform-provider-netbox/netbox/client" ) +var supportedVersions = []string{ + "3.7.0", + "3.7.1", + "3.7.2", + "3.7.3", + "3.7.4", + "3.7.5", + "3.7.6", + "3.7.7", + "3.7.8", +} + +// Config is a container struct passed to the provider functions as meta argument. +type Config struct { + Client *netbox.APIClient + LegacyClient *netboxlegacy.NetBoxAPI +} + // This makes the description contain the default value, particularly useful for the docs // From https://github.com/hashicorp/terraform-plugin-docs/issues/65#issuecomment-1152842370 func init() { @@ -239,7 +260,8 @@ func Provider() *schema.Provider { func providerConfigure(ctx context.Context, data *schema.ResourceData) (interface{}, diag.Diagnostics) { var diags diag.Diagnostics - config := Config{ + cfg := client.Config{ + ServerURL: data.Get("server_url").(string), APIToken: data.Get("api_token").(string), AllowInsecureHTTPS: data.Get("allow_insecure_https").(bool), Headers: data.Get("headers").(map[string]interface{}), @@ -247,52 +269,41 @@ func providerConfigure(ctx context.Context, data *schema.ResourceData) (interfac StripTrailingSlashesFromURL: data.Get("strip_trailing_slashes_from_url").(bool), } - serverURL := data.Get("server_url").(string) - // Unless explicitly switched off, strip trailing slashes from the server url // Trailing slashes cause errors as seen in https://github.com/e-breuninger/terraform-provider-netbox/issues/198 // and https://github.com/e-breuninger/terraform-provider-netbox/issues/300 stripTrailingSlashesFromURL := data.Get("strip_trailing_slashes_from_url").(bool) - if stripTrailingSlashesFromURL { - trimmed := false - - // This is Go's poor man's while loop - for strings.HasSuffix(serverURL, "/") { - serverURL = strings.TrimRight(serverURL, "/") - trimmed = true - } - if trimmed { - diags = append(diags, diag.Diagnostic{ - Severity: diag.Warning, - Summary: "Stripped trailing slashes from the `server_url` parameter", - Detail: "Trailing slashes in the `server_url` parameter lead to problems in most setups, so all trailing slashes were stripped. Use the `strip_trailing_slashes_from_url` parameter to disable this feature or remove all trailing slashes in the `server_url` to disable this warning.", - }) - } + if stripTrailingSlashesFromURL && strings.HasSuffix(cfg.ServerURL, "/") { + cfg.ServerURL = strings.TrimRight(cfg.ServerURL, "/") + diags = append(diags, diag.Diagnostic{ + Severity: diag.Warning, + Summary: "Stripped trailing slashes from the `server_url` parameter", + Detail: "Trailing slashes in the `server_url` parameter lead to problems in most setups, so all trailing slashes were stripped. Use the `strip_trailing_slashes_from_url` parameter to disable this feature or remove all trailing slashes in the `server_url` to disable this warning.", + }) } - config.ServerURL = serverURL + apiClient, err := client.NewClient(&cfg) + if err != nil { + return nil, diag.Errorf("initializing netbox client: %s", err) + } - netboxClient, clientError := config.Client() - if clientError != nil { - return nil, diag.FromErr(clientError) + legacyClient, err := client.NewLegacyClient(&cfg) + if err != nil { + return nil, diag.Errorf("initializing netbox legacy client: %s", err) } - // Unless explicitly switched off, use the client to retrieve the Netbox version - // so we can determine compatibility of the provider with the used Netbox + // // Unless explicitly switched off, use the client to retrieve the Netbox version + // // so we can determine compatibility of the provider with the used Netbox skipVersionCheck := data.Get("skip_version_check").(bool) - if !skipVersionCheck { - req := status.NewStatusListParams() - res, err := netboxClient.Status.StatusList(req, nil) + req := apiClient.StatusAPI.StatusRetrieve(context.Background()) + payload, _, err := req.Execute() if err != nil { - return nil, diag.FromErr(err) + return nil, diag.Errorf("getting netbox status: %s", err) } - netboxVersion := res.GetPayload().(map[string]interface{})["netbox-version"].(string) - - supportedVersions := []string{"3.7.0", "3.7.1", "3.7.2", "3.7.3", "3.7.4", "3.7.5", "3.7.6", "3.7.7", "3.7.8"} - + netboxVersion := payload["netbox-version"].(string) if !slices.Contains(supportedVersions, netboxVersion) { // Currently, there is no way to test these warnings. There is an issue to track this: https://github.com/hashicorp/terraform-plugin-sdk/issues/864 diags = append(diags, diag.Diagnostic{ @@ -303,5 +314,8 @@ func providerConfigure(ctx context.Context, data *schema.ResourceData) (interfac } } - return netboxClient, diags + return &Config{ + Client: apiClient, + LegacyClient: legacyClient, + }, diags } diff --git a/netbox/provider_test.go b/netbox/provider_test.go index d372918d..db33eaa8 100644 --- a/netbox/provider_test.go +++ b/netbox/provider_test.go @@ -8,6 +8,7 @@ import ( "strings" "testing" + "github.com/e-breuninger/terraform-provider-netbox/netbox/client" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -55,16 +56,25 @@ func providerInvalidConfigure() schema.ConfigureContextFunc { return func(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { var diags diag.Diagnostics - config := &Config{} - config.ServerURL = "https://fake.netbox.server" - config.APIToken = "1234567890" + config := &client.Config{ + ServerURL: "https://fake.netbox.server", + APIToken: "1234567890", + } + + legacyClient, err := client.NewLegacyClient(config) + if err != nil { + return nil, diag.FromErr(err) + } - netboxClient, clientError := config.Client() - if clientError != nil { - return nil, diag.FromErr(clientError) + apiClient, err := client.NewClient(config) + if err != nil { + return nil, diag.FromErr(err) } - return netboxClient, diags + return &Config{ + Client: apiClient, + LegacyClient: legacyClient, + }, diags } } diff --git a/netbox/resource_netbox_aggregate.go b/netbox/resource_netbox_aggregate.go index 40c22953..51f7e9dc 100644 --- a/netbox/resource_netbox_aggregate.go +++ b/netbox/resource_netbox_aggregate.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -47,7 +46,7 @@ func resourceNetboxAggregate() *schema.Resource { } } func resourceNetboxAggregateCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableAggregate{} prefix := d.Get("prefix").(string) @@ -77,7 +76,7 @@ func resourceNetboxAggregateCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxAggregateRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamAggregatesReadParams().WithID(id) @@ -117,7 +116,7 @@ func resourceNetboxAggregateRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxAggregateUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableAggregate{} prefix := d.Get("prefix").(string) @@ -145,7 +144,7 @@ func resourceNetboxAggregateUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxAggregateDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamAggregatesDeleteParams().WithID(id) _, err := api.Ipam.IpamAggregatesDelete(params, nil) diff --git a/netbox/resource_netbox_aggregate_test.go b/netbox/resource_netbox_aggregate_test.go index 68db28c2..c92233d0 100644 --- a/netbox/resource_netbox_aggregate_test.go +++ b/netbox/resource_netbox_aggregate_test.go @@ -5,7 +5,6 @@ import ( "log" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -55,7 +54,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamAggregatesListParams() res, err := api.Ipam.IpamAggregatesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_asn.go b/netbox/resource_netbox_asn.go index 756fc5e8..02a8be17 100644 --- a/netbox/resource_netbox_asn.go +++ b/netbox/resource_netbox_asn.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -39,7 +38,7 @@ func resourceNetboxAsn() *schema.Resource { } func resourceNetboxAsnCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableASN{} @@ -64,7 +63,7 @@ func resourceNetboxAsnCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxAsnRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamAsnsReadParams().WithID(id) @@ -92,7 +91,7 @@ func resourceNetboxAsnRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxAsnUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableASN{} @@ -116,7 +115,7 @@ func resourceNetboxAsnUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxAsnDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamAsnsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_asn_test.go b/netbox/resource_netbox_asn_test.go index 849806f7..0174bec9 100644 --- a/netbox/resource_netbox_asn_test.go +++ b/netbox/resource_netbox_asn_test.go @@ -5,7 +5,6 @@ import ( "log" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -91,7 +90,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamAsnsListParams() res, err := api.Ipam.IpamAsnsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_available_ip_address.go b/netbox/resource_netbox_available_ip_address.go index 5e2a1869..c4091dbd 100644 --- a/netbox/resource_netbox_available_ip_address.go +++ b/netbox/resource_netbox_available_ip_address.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -106,7 +105,7 @@ This resource will retrieve the next available IP address from a given prefix or } func resourceNetboxAvailableIPAddressCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient prefixID := int64(d.Get("prefix_id").(int)) vrfID := int64(int64(d.Get("vrf_id").(int))) rangeID := int64(d.Get("ip_range_id").(int)) @@ -134,7 +133,7 @@ func resourceNetboxAvailableIPAddressCreate(d *schema.ResourceData, m interface{ } func resourceNetboxAvailableIPAddressRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamIPAddressesReadParams().WithID(id) @@ -196,7 +195,7 @@ func resourceNetboxAvailableIPAddressRead(d *schema.ResourceData, m interface{}) } func resourceNetboxAvailableIPAddressUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableIPAddress{} @@ -249,7 +248,7 @@ func resourceNetboxAvailableIPAddressUpdate(d *schema.ResourceData, m interface{ } func resourceNetboxAvailableIPAddressDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamIPAddressesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_available_ip_address_test.go b/netbox/resource_netbox_available_ip_address_test.go index de5a9f7f..667f156b 100644 --- a/netbox/resource_netbox_available_ip_address_test.go +++ b/netbox/resource_netbox_available_ip_address_test.go @@ -6,7 +6,6 @@ import ( "regexp" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -294,7 +293,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamIPAddressesListParams() res, err := api.Ipam.IpamIPAddressesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_available_prefix.go b/netbox/resource_netbox_available_prefix.go index fc8baa08..36b6c893 100644 --- a/netbox/resource_netbox_available_prefix.go +++ b/netbox/resource_netbox_available_prefix.go @@ -6,7 +6,6 @@ import ( "strconv" "strings" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -115,7 +114,7 @@ func resourceNetboxAvailablePrefixParseImport(importStr string) (int, string, in } func resourceNetboxAvailablePrefixCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient parentPrefixID := int64(d.Get("parent_prefix_id").(int)) prefixLength := int64(d.Get("prefix_length").(int)) diff --git a/netbox/resource_netbox_available_prefix_test.go b/netbox/resource_netbox_available_prefix_test.go index fc673747..7b53407c 100644 --- a/netbox/resource_netbox_available_prefix_test.go +++ b/netbox/resource_netbox_available_prefix_test.go @@ -5,7 +5,6 @@ import ( "regexp" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -175,7 +174,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamPrefixesListParams() res, err := api.Ipam.IpamPrefixesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_cable.go b/netbox/resource_netbox_cable.go index 1b787624..80f0d0a1 100644 --- a/netbox/resource_netbox_cable.go +++ b/netbox/resource_netbox_cable.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -90,7 +89,7 @@ func resourceNetboxCable() *schema.Resource { } func resourceNetboxCableCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableCable{ Status: d.Get("status").(string), @@ -130,7 +129,7 @@ func resourceNetboxCableCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxCableRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimCablesReadParams().WithID(id) @@ -188,7 +187,7 @@ func resourceNetboxCableRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxCableUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -228,7 +227,7 @@ func resourceNetboxCableUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxCableDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimCablesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_cable_test.go b/netbox/resource_netbox_cable_test.go index b025ca2e..178291df 100644 --- a/netbox/resource_netbox_cable_test.go +++ b/netbox/resource_netbox_cable_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -204,7 +203,7 @@ resource "netbox_cable" "test" { func testAccCheckCableDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each cable // is destroyed @@ -244,7 +243,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimCablesListParams() res, err := api.Dcim.DcimCablesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_circuit.go b/netbox/resource_netbox_circuit.go index b54feeca..cd4e9e89 100644 --- a/netbox/resource_netbox_circuit.go +++ b/netbox/resource_netbox_circuit.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/circuits" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -56,7 +55,7 @@ func resourceNetboxCircuit() *schema.Resource { } func resourceNetboxCircuitCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableCircuit{} @@ -95,7 +94,7 @@ func resourceNetboxCircuitCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxCircuitRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := circuits.NewCircuitsCircuitsReadParams().WithID(id) @@ -138,7 +137,7 @@ func resourceNetboxCircuitRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxCircuitUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableCircuit{} @@ -176,7 +175,7 @@ func resourceNetboxCircuitUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxCircuitDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := circuits.NewCircuitsCircuitsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_circuit_provider.go b/netbox/resource_netbox_circuit_provider.go index 75a210b8..50c4a712 100644 --- a/netbox/resource_netbox_circuit_provider.go +++ b/netbox/resource_netbox_circuit_provider.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/circuits" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -42,7 +41,7 @@ func resourceNetboxCircuitProvider() *schema.Resource { } func resourceNetboxCircuitProviderCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableProvider{} @@ -73,7 +72,7 @@ func resourceNetboxCircuitProviderCreate(d *schema.ResourceData, m interface{}) } func resourceNetboxCircuitProviderRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := circuits.NewCircuitsProvidersReadParams().WithID(id) @@ -98,7 +97,7 @@ func resourceNetboxCircuitProviderRead(d *schema.ResourceData, m interface{}) er } func resourceNetboxCircuitProviderUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableProvider{} @@ -128,7 +127,7 @@ func resourceNetboxCircuitProviderUpdate(d *schema.ResourceData, m interface{}) } func resourceNetboxCircuitProviderDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := circuits.NewCircuitsProvidersDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_circuit_provider_test.go b/netbox/resource_netbox_circuit_provider_test.go index 360b321c..fc0c0ca7 100644 --- a/netbox/resource_netbox_circuit_provider_test.go +++ b/netbox/resource_netbox_circuit_provider_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/circuits" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -59,7 +58,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := circuits.NewCircuitsProvidersListParams() res, err := api.Circuits.CircuitsProvidersList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_circuit_termination.go b/netbox/resource_netbox_circuit_termination.go index 01454edb..8d414901 100644 --- a/netbox/resource_netbox_circuit_termination.go +++ b/netbox/resource_netbox_circuit_termination.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/circuits" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -58,7 +57,7 @@ func resourceNetboxCircuitTermination() *schema.Resource { } func resourceNetboxCircuitTerminationCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableCircuitTermination{} @@ -105,7 +104,7 @@ func resourceNetboxCircuitTerminationCreate(d *schema.ResourceData, m interface{ } func resourceNetboxCircuitTerminationRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := circuits.NewCircuitsCircuitTerminationsReadParams().WithID(id) @@ -162,7 +161,7 @@ func resourceNetboxCircuitTerminationRead(d *schema.ResourceData, m interface{}) } func resourceNetboxCircuitTerminationUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableCircuitTermination{} @@ -208,7 +207,7 @@ func resourceNetboxCircuitTerminationUpdate(d *schema.ResourceData, m interface{ } func resourceNetboxCircuitTerminationDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := circuits.NewCircuitsCircuitTerminationsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_circuit_termination_test.go b/netbox/resource_netbox_circuit_termination_test.go index d7fb9559..12541856 100644 --- a/netbox/resource_netbox_circuit_termination_test.go +++ b/netbox/resource_netbox_circuit_termination_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/circuits" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -72,7 +71,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := circuits.NewCircuitsCircuitsListParams() res, err := api.Circuits.CircuitsCircuitsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_circuit_test.go b/netbox/resource_netbox_circuit_test.go index b907776b..dad75351 100644 --- a/netbox/resource_netbox_circuit_test.go +++ b/netbox/resource_netbox_circuit_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/circuits" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -83,7 +82,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := circuits.NewCircuitsCircuitsListParams() res, err := api.Circuits.CircuitsCircuitsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_circuit_type.go b/netbox/resource_netbox_circuit_type.go index 063fbb35..e64725a8 100644 --- a/netbox/resource_netbox_circuit_type.go +++ b/netbox/resource_netbox_circuit_type.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/circuits" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -40,7 +39,7 @@ func resourceNetboxCircuitType() *schema.Resource { } func resourceNetboxCircuitTypeCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.CircuitType{} @@ -70,7 +69,7 @@ func resourceNetboxCircuitTypeCreate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxCircuitTypeRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := circuits.NewCircuitsCircuitTypesReadParams().WithID(id) @@ -95,7 +94,7 @@ func resourceNetboxCircuitTypeRead(d *schema.ResourceData, m interface{}) error } func resourceNetboxCircuitTypeUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.CircuitType{} @@ -124,7 +123,7 @@ func resourceNetboxCircuitTypeUpdate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxCircuitTypeDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := circuits.NewCircuitsCircuitTypesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_circuit_type_test.go b/netbox/resource_netbox_circuit_type_test.go index 631ed95e..6866d6de 100644 --- a/netbox/resource_netbox_circuit_type_test.go +++ b/netbox/resource_netbox_circuit_type_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/circuits" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -48,7 +47,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := circuits.NewCircuitsCircuitTypesListParams() res, err := api.Circuits.CircuitsCircuitTypesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_cluster.go b/netbox/resource_netbox_cluster.go index b9bdc2e4..d3c97f00 100644 --- a/netbox/resource_netbox_cluster.go +++ b/netbox/resource_netbox_cluster.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -60,7 +59,7 @@ func resourceNetboxCluster() *schema.Resource { } func resourceNetboxClusterCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableCluster{} @@ -105,7 +104,7 @@ func resourceNetboxClusterCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxClusterRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := virtualization.NewVirtualizationClustersReadParams().WithID(id) @@ -151,7 +150,7 @@ func resourceNetboxClusterRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxClusterUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableCluster{} @@ -194,7 +193,7 @@ func resourceNetboxClusterUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxClusterDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := virtualization.NewVirtualizationClustersDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_cluster_group.go b/netbox/resource_netbox_cluster_group.go index 4464de5d..d557c9f0 100644 --- a/netbox/resource_netbox_cluster_group.go +++ b/netbox/resource_netbox_cluster_group.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -44,7 +43,7 @@ func resourceNetboxClusterGroup() *schema.Resource { } func resourceNetboxClusterGroupCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.ClusterGroup{} @@ -80,7 +79,7 @@ func resourceNetboxClusterGroupCreate(d *schema.ResourceData, m interface{}) err } func resourceNetboxClusterGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := virtualization.NewVirtualizationClusterGroupsReadParams().WithID(id) @@ -104,7 +103,7 @@ func resourceNetboxClusterGroupRead(d *schema.ResourceData, m interface{}) error } func resourceNetboxClusterGroupUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.ClusterGroup{} @@ -144,7 +143,7 @@ func resourceNetboxClusterGroupUpdate(d *schema.ResourceData, m interface{}) err } func resourceNetboxClusterGroupDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := virtualization.NewVirtualizationClusterGroupsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_cluster_group_test.go b/netbox/resource_netbox_cluster_group_test.go index e6341ba1..7f65c686 100644 --- a/netbox/resource_netbox_cluster_group_test.go +++ b/netbox/resource_netbox_cluster_group_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -72,7 +71,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := virtualization.NewVirtualizationClusterGroupsListParams() res, err := api.Virtualization.VirtualizationClusterGroupsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_cluster_test.go b/netbox/resource_netbox_cluster_test.go index 882f0d2b..991ec2a4 100644 --- a/netbox/resource_netbox_cluster_test.go +++ b/netbox/resource_netbox_cluster_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -119,7 +118,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := virtualization.NewVirtualizationClustersListParams() res, err := api.Virtualization.VirtualizationClustersList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_cluster_type.go b/netbox/resource_netbox_cluster_type.go index 81bfce51..80a03238 100644 --- a/netbox/resource_netbox_cluster_type.go +++ b/netbox/resource_netbox_cluster_type.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -40,7 +39,7 @@ func resourceNetboxClusterType() *schema.Resource { } func resourceNetboxClusterTypeCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) slugValue, slugOk := d.GetOk("slug") @@ -73,7 +72,7 @@ func resourceNetboxClusterTypeCreate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxClusterTypeRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := virtualization.NewVirtualizationClusterTypesReadParams().WithID(id) @@ -96,7 +95,7 @@ func resourceNetboxClusterTypeRead(d *schema.ResourceData, m interface{}) error } func resourceNetboxClusterTypeUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.ClusterType{} @@ -127,7 +126,7 @@ func resourceNetboxClusterTypeUpdate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxClusterTypeDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := virtualization.NewVirtualizationClusterTypesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_cluster_type_test.go b/netbox/resource_netbox_cluster_type_test.go index 1a42c350..49d38389 100644 --- a/netbox/resource_netbox_cluster_type_test.go +++ b/netbox/resource_netbox_cluster_type_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -68,7 +67,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := virtualization.NewVirtualizationClusterTypesListParams() res, err := api.Virtualization.VirtualizationClusterTypesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_contact.go b/netbox/resource_netbox_contact.go index af025c9c..b55b1ce7 100644 --- a/netbox/resource_netbox_contact.go +++ b/netbox/resource_netbox_contact.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/fbreckle/go-netbox/netbox/models" "github.com/go-openapi/strfmt" @@ -49,7 +48,7 @@ func resourceNetboxContact() *schema.Resource { } func resourceNetboxContactCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) phone := d.Get("phone").(string) @@ -82,7 +81,7 @@ func resourceNetboxContactCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxContactRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyContactsReadParams().WithID(id) @@ -110,7 +109,7 @@ func resourceNetboxContactRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxContactUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableContact{} @@ -141,7 +140,7 @@ func resourceNetboxContactUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxContactDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyContactsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_contact_assignment.go b/netbox/resource_netbox_contact_assignment.go index 964df9f4..1d6d2172 100644 --- a/netbox/resource_netbox_contact_assignment.go +++ b/netbox/resource_netbox_contact_assignment.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -54,7 +53,7 @@ func resourceNetboxContactAssignment() *schema.Resource { } func resourceNetboxContactAssignmentCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient contentType := d.Get("content_type").(string) objectID := int64(d.Get("object_id").(int)) @@ -83,7 +82,7 @@ func resourceNetboxContactAssignmentCreate(d *schema.ResourceData, m interface{} } func resourceNetboxContactAssignmentRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyContactAssignmentsReadParams().WithID(id) @@ -119,7 +118,7 @@ func resourceNetboxContactAssignmentRead(d *schema.ResourceData, m interface{}) } func resourceNetboxContactAssignmentUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableContactAssignment{} @@ -153,7 +152,7 @@ func resourceNetboxContactAssignmentUpdate(d *schema.ResourceData, m interface{} } func resourceNetboxContactAssignmentDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyContactAssignmentsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_contact_assignment_test.go b/netbox/resource_netbox_contact_assignment_test.go index 0c16096a..2f518b53 100644 --- a/netbox/resource_netbox_contact_assignment_test.go +++ b/netbox/resource_netbox_contact_assignment_test.go @@ -5,7 +5,6 @@ import ( "log" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -80,7 +79,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyContactAssignmentsListParams() res, err := api.Tenancy.TenancyContactAssignmentsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_contact_group.go b/netbox/resource_netbox_contact_group.go index 182a1f6b..fbbe5095 100644 --- a/netbox/resource_netbox_contact_group.go +++ b/netbox/resource_netbox_contact_group.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -48,7 +47,7 @@ func resourceNetboxContactGroup() *schema.Resource { } func resourceNetboxContactGroupCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) parentID := int64(d.Get("parent_id").(int)) @@ -86,7 +85,7 @@ func resourceNetboxContactGroupCreate(d *schema.ResourceData, m interface{}) err } func resourceNetboxContactGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyContactGroupsReadParams().WithID(id) @@ -114,7 +113,7 @@ func resourceNetboxContactGroupRead(d *schema.ResourceData, m interface{}) error } func resourceNetboxContactGroupUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableContactGroup{} @@ -151,7 +150,7 @@ func resourceNetboxContactGroupUpdate(d *schema.ResourceData, m interface{}) err } func resourceNetboxContactGroupDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyContactGroupsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_contact_group_test.go b/netbox/resource_netbox_contact_group_test.go index e1e0513a..2a564563 100644 --- a/netbox/resource_netbox_contact_group_test.go +++ b/netbox/resource_netbox_contact_group_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -65,7 +64,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyContactGroupsListParams() res, err := api.Tenancy.TenancyContactGroupsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_contact_role.go b/netbox/resource_netbox_contact_role.go index 5aafc410..a59d0dfa 100644 --- a/netbox/resource_netbox_contact_role.go +++ b/netbox/resource_netbox_contact_role.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -40,7 +39,7 @@ func resourceNetboxContactRole() *schema.Resource { } func resourceNetboxContactRoleCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) @@ -70,7 +69,7 @@ func resourceNetboxContactRoleCreate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxContactRoleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyContactRolesReadParams().WithID(id) @@ -96,7 +95,7 @@ func resourceNetboxContactRoleRead(d *schema.ResourceData, m interface{}) error } func resourceNetboxContactRoleUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.ContactRole{} @@ -124,7 +123,7 @@ func resourceNetboxContactRoleUpdate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxContactRoleDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyContactRolesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_contact_role_test.go b/netbox/resource_netbox_contact_role_test.go index 811a8727..270518e4 100644 --- a/netbox/resource_netbox_contact_role_test.go +++ b/netbox/resource_netbox_contact_role_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -48,7 +47,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyContactRolesListParams() res, err := api.Tenancy.TenancyContactRolesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_contact_test.go b/netbox/resource_netbox_contact_test.go index 487e1b75..34053d9b 100644 --- a/netbox/resource_netbox_contact_test.go +++ b/netbox/resource_netbox_contact_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -114,7 +113,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyContactsListParams() res, err := api.Tenancy.TenancyContactsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_custom_field.go b/netbox/resource_netbox_custom_field.go index 73676db2..ffffe046 100644 --- a/netbox/resource_netbox_custom_field.go +++ b/netbox/resource_netbox_custom_field.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -101,7 +100,7 @@ func resourceCustomField() *schema.Resource { } func resourceNetboxCustomFieldUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -149,7 +148,7 @@ func resourceNetboxCustomFieldUpdate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxCustomFieldCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := &models.WritableCustomField{ Name: strToPtr(d.Get("name").(string)), @@ -197,7 +196,7 @@ func resourceNetboxCustomFieldCreate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxCustomFieldRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasCustomFieldsReadParams().WithID(id) res, err := api.Extras.ExtrasCustomFieldsRead(params, nil) @@ -243,7 +242,7 @@ func resourceNetboxCustomFieldRead(d *schema.ResourceData, m interface{}) error } func resourceNetboxCustomFieldDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasCustomFieldsDeleteParams().WithID(id) _, err := api.Extras.ExtrasCustomFieldsDelete(params, nil) diff --git a/netbox/resource_netbox_custom_field_choice_set.go b/netbox/resource_netbox_custom_field_choice_set.go index 27d4dc4b..cbec3741 100644 --- a/netbox/resource_netbox_custom_field_choice_set.go +++ b/netbox/resource_netbox_custom_field_choice_set.go @@ -4,7 +4,6 @@ import ( "errors" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -85,7 +84,7 @@ A choice set must define a base choice set and/or a set of arbitrary extra choic } func resourceNetboxCustomFieldChoiceSetCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) @@ -122,7 +121,7 @@ func resourceNetboxCustomFieldChoiceSetCreate(d *schema.ResourceData, m interfac } func resourceNetboxCustomFieldChoiceSetRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasCustomFieldChoiceSetsReadParams().WithID(id) @@ -154,7 +153,7 @@ func resourceNetboxCustomFieldChoiceSetRead(d *schema.ResourceData, m interface{ } func resourceNetboxCustomFieldChoiceSetUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -191,7 +190,7 @@ func resourceNetboxCustomFieldChoiceSetUpdate(d *schema.ResourceData, m interfac } func resourceNetboxCustomFieldChoiceSetDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasCustomFieldChoiceSetsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device.go b/netbox/resource_netbox_device.go index 2c65b4ac..8668b338 100644 --- a/netbox/resource_netbox_device.go +++ b/netbox/resource_netbox_device.go @@ -5,7 +5,6 @@ import ( "encoding/json" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -139,7 +138,7 @@ func resourceNetboxDevice() *schema.Resource { } func resourceNetboxDeviceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) @@ -257,7 +256,7 @@ func resourceNetboxDeviceCreate(ctx context.Context, d *schema.ResourceData, m i } func resourceNetboxDeviceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient var diags diag.Diagnostics @@ -389,7 +388,7 @@ func resourceNetboxDeviceRead(ctx context.Context, d *schema.ResourceData, m int } func resourceNetboxDeviceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableDeviceWithConfigContext{} @@ -546,7 +545,7 @@ func resourceNetboxDeviceUpdate(ctx context.Context, d *schema.ResourceData, m i } func resourceNetboxDeviceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient var diags diag.Diagnostics diff --git a/netbox/resource_netbox_device_console_port.go b/netbox/resource_netbox_device_console_port.go index 4336dbbf..34c5a08e 100644 --- a/netbox/resource_netbox_device_console_port.go +++ b/netbox/resource_netbox_device_console_port.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -66,7 +65,7 @@ func resourceNetboxDeviceConsolePort() *schema.Resource { } func resourceNetboxDeviceConsolePortCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableConsolePort{ Device: int64ToPtr(int64(d.Get("device_id").(int))), @@ -99,7 +98,7 @@ func resourceNetboxDeviceConsolePortCreate(d *schema.ResourceData, m interface{} } func resourceNetboxDeviceConsolePortRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimConsolePortsReadParams().WithID(id) @@ -157,7 +156,7 @@ func resourceNetboxDeviceConsolePortRead(d *schema.ResourceData, m interface{}) } func resourceNetboxDeviceConsolePortUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -190,7 +189,7 @@ func resourceNetboxDeviceConsolePortUpdate(d *schema.ResourceData, m interface{} } func resourceNetboxDeviceConsolePortDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimConsolePortsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_console_port_test.go b/netbox/resource_netbox_device_console_port_test.go index f89afaae..cc5c23cd 100644 --- a/netbox/resource_netbox_device_console_port_test.go +++ b/netbox/resource_netbox_device_console_port_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -135,7 +134,7 @@ resource "netbox_device_console_port" "test" { func testAccCheckDeviceConsolePortDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each console port // is destroyed @@ -175,7 +174,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimConsolePortsListParams() res, err := api.Dcim.DcimConsolePortsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_console_server_port.go b/netbox/resource_netbox_device_console_server_port.go index c7439468..231810c9 100644 --- a/netbox/resource_netbox_device_console_server_port.go +++ b/netbox/resource_netbox_device_console_server_port.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -66,7 +65,7 @@ func resourceNetboxDeviceConsoleServerPort() *schema.Resource { } func resourceNetboxDeviceConsoleServerPortCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableConsoleServerPort{ Device: int64ToPtr(int64(d.Get("device_id").(int))), @@ -99,7 +98,7 @@ func resourceNetboxDeviceConsoleServerPortCreate(d *schema.ResourceData, m inter } func resourceNetboxDeviceConsoleServerPortRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimConsoleServerPortsReadParams().WithID(id) @@ -157,7 +156,7 @@ func resourceNetboxDeviceConsoleServerPortRead(d *schema.ResourceData, m interfa } func resourceNetboxDeviceConsoleServerPortUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -190,7 +189,7 @@ func resourceNetboxDeviceConsoleServerPortUpdate(d *schema.ResourceData, m inter } func resourceNetboxDeviceConsoleServerPortDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimConsoleServerPortsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_console_server_port_test.go b/netbox/resource_netbox_device_console_server_port_test.go index 97f3fb6e..a312308c 100644 --- a/netbox/resource_netbox_device_console_server_port_test.go +++ b/netbox/resource_netbox_device_console_server_port_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -135,7 +134,7 @@ resource "netbox_device_console_server_port" "test" { func testAccCheckDeviceConsoleServerPortDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each console server port // is destroyed @@ -175,7 +174,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimConsoleServerPortsListParams() res, err := api.Dcim.DcimConsoleServerPortsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_front_port.go b/netbox/resource_netbox_device_front_port.go index 10a3fc33..b3d0a108 100644 --- a/netbox/resource_netbox_device_front_port.go +++ b/netbox/resource_netbox_device_front_port.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -73,7 +72,7 @@ func resourceNetboxDeviceFrontPort() *schema.Resource { } func resourceNetboxDeviceFrontPortCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableFrontPort{ Device: int64ToPtr(int64(d.Get("device_id").(int))), @@ -108,7 +107,7 @@ func resourceNetboxDeviceFrontPortCreate(d *schema.ResourceData, m interface{}) } func resourceNetboxDeviceFrontPortRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimFrontPortsReadParams().WithID(id) @@ -169,7 +168,7 @@ func resourceNetboxDeviceFrontPortRead(d *schema.ResourceData, m interface{}) er } func resourceNetboxDeviceFrontPortUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -204,7 +203,7 @@ func resourceNetboxDeviceFrontPortUpdate(d *schema.ResourceData, m interface{}) } func resourceNetboxDeviceFrontPortDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimFrontPortsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_front_port_test.go b/netbox/resource_netbox_device_front_port_test.go index 58de210b..abfee460 100644 --- a/netbox/resource_netbox_device_front_port_test.go +++ b/netbox/resource_netbox_device_front_port_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -152,7 +151,7 @@ resource "netbox_device_front_port" "test" { func testAccCheckDeviceFrontPortDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each front port // is destroyed @@ -192,7 +191,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimFrontPortsListParams() res, err := api.Dcim.DcimFrontPortsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_interface.go b/netbox/resource_netbox_device_interface.go index 8d16fc8d..d19eb3d4 100644 --- a/netbox/resource_netbox_device_interface.go +++ b/netbox/resource_netbox_device_interface.go @@ -5,7 +5,6 @@ import ( "strconv" "strings" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -105,7 +104,7 @@ func resourceNetboxDeviceInterface() *schema.Resource { } func resourceNetboxDeviceInterfaceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient var diags diag.Diagnostics @@ -167,7 +166,7 @@ func resourceNetboxDeviceInterfaceCreate(ctx context.Context, d *schema.Resource } func resourceNetboxDeviceInterfaceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) var diags diag.Diagnostics @@ -218,7 +217,7 @@ func resourceNetboxDeviceInterfaceRead(ctx context.Context, d *schema.ResourceDa } func resourceNetboxDeviceInterfaceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient var diags diag.Diagnostics @@ -286,7 +285,7 @@ func resourceNetboxDeviceInterfaceUpdate(ctx context.Context, d *schema.Resource } func resourceNetboxDeviceInterfaceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimInterfacesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_interface_test.go b/netbox/resource_netbox_device_interface_test.go index f5a5baed..e7b351ea 100644 --- a/netbox/resource_netbox_device_interface_test.go +++ b/netbox/resource_netbox_device_interface_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -305,7 +304,7 @@ func TestAccNetboxDeviceInterface_vlans(t *testing.T) { func testAccCheckDeviceInterfaceDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each interface // is destroyed @@ -345,7 +344,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimInterfacesListParams() res, err := api.Dcim.DcimInterfacesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_module_bay.go b/netbox/resource_netbox_device_module_bay.go index 6f5998a7..2d09ba05 100644 --- a/netbox/resource_netbox_device_module_bay.go +++ b/netbox/resource_netbox_device_module_bay.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -53,7 +52,7 @@ func resourceNetboxDeviceModuleBay() *schema.Resource { } func resourceNetboxDeviceModuleBayCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableModuleBay{ Device: int64ToPtr(int64(d.Get("device_id").(int))), @@ -83,7 +82,7 @@ func resourceNetboxDeviceModuleBayCreate(d *schema.ResourceData, m interface{}) } func resourceNetboxDeviceModuleBayRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimModuleBaysReadParams().WithID(id) @@ -122,7 +121,7 @@ func resourceNetboxDeviceModuleBayRead(d *schema.ResourceData, m interface{}) er } func resourceNetboxDeviceModuleBayUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -152,7 +151,7 @@ func resourceNetboxDeviceModuleBayUpdate(d *schema.ResourceData, m interface{}) } func resourceNetboxDeviceModuleBayDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimModuleBaysDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_module_bay_test.go b/netbox/resource_netbox_device_module_bay_test.go index e587680b..3638a73e 100644 --- a/netbox/resource_netbox_device_module_bay_test.go +++ b/netbox/resource_netbox_device_module_bay_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -108,7 +107,7 @@ resource "netbox_device_module_bay" "test" { func testAccCheckDeviceModuleBayDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each module bay // is destroyed @@ -148,7 +147,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimModuleBaysListParams() res, err := api.Dcim.DcimModuleBaysList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_power_feed.go b/netbox/resource_netbox_device_power_feed.go index 39cb5361..4ffb1a85 100644 --- a/netbox/resource_netbox_device_power_feed.go +++ b/netbox/resource_netbox_device_power_feed.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -94,7 +93,7 @@ func resourceNetboxPowerFeed() *schema.Resource { } func resourceNetboxPowerFeedCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritablePowerFeed{ PowerPanel: int64ToPtr(int64(d.Get("power_panel_id").(int))), @@ -132,7 +131,7 @@ func resourceNetboxPowerFeedCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxPowerFeedRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPowerFeedsReadParams().WithID(id) @@ -206,7 +205,7 @@ func resourceNetboxPowerFeedRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPowerFeedUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -244,7 +243,7 @@ func resourceNetboxPowerFeedUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxPowerFeedDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPowerFeedsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_power_feed_test.go b/netbox/resource_netbox_device_power_feed_test.go index 494c6606..db6ebd7f 100644 --- a/netbox/resource_netbox_device_power_feed_test.go +++ b/netbox/resource_netbox_device_power_feed_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -139,7 +138,7 @@ resource "netbox_power_feed" "test" { func testAccCheckDevicePowerFeedDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each power feed // is destroyed @@ -179,7 +178,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimPowerFeedsListParams() res, err := api.Dcim.DcimPowerFeedsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_power_outlet.go b/netbox/resource_netbox_device_power_outlet.go index 6f79a3f0..d5bd2dad 100644 --- a/netbox/resource_netbox_device_power_outlet.go +++ b/netbox/resource_netbox_device_power_outlet.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -74,7 +73,7 @@ For example, imagine a PDU with one power port which draws from a three-phase fe } func resourceNetboxDevicePowerOutletCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritablePowerOutlet{ Device: int64ToPtr(int64(d.Get("device_id").(int))), @@ -108,7 +107,7 @@ func resourceNetboxDevicePowerOutletCreate(d *schema.ResourceData, m interface{} } func resourceNetboxDevicePowerOutletRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPowerOutletsReadParams().WithID(id) @@ -173,7 +172,7 @@ func resourceNetboxDevicePowerOutletRead(d *schema.ResourceData, m interface{}) } func resourceNetboxDevicePowerOutletUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -207,7 +206,7 @@ func resourceNetboxDevicePowerOutletUpdate(d *schema.ResourceData, m interface{} } func resourceNetboxDevicePowerOutletDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPowerOutletsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_power_outlet_test.go b/netbox/resource_netbox_device_power_outlet_test.go index 19ecf456..63264045 100644 --- a/netbox/resource_netbox_device_power_outlet_test.go +++ b/netbox/resource_netbox_device_power_outlet_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -143,7 +142,7 @@ resource "netbox_device_power_outlet" "test" { func testAccCheckDevicePowerOutletDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each power outlet // is destroyed @@ -183,7 +182,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimPowerOutletsListParams() res, err := api.Dcim.DcimPowerOutletsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_power_port.go b/netbox/resource_netbox_device_power_port.go index d0ae078f..597d5055 100644 --- a/netbox/resource_netbox_device_power_port.go +++ b/netbox/resource_netbox_device_power_port.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -69,7 +68,7 @@ func resourceNetboxDevicePowerPort() *schema.Resource { } func resourceNetboxDevicePowerPortCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritablePowerPort{ Device: int64ToPtr(int64(d.Get("device_id").(int))), @@ -103,7 +102,7 @@ func resourceNetboxDevicePowerPortCreate(d *schema.ResourceData, m interface{}) } func resourceNetboxDevicePowerPortRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPowerPortsReadParams().WithID(id) @@ -159,7 +158,7 @@ func resourceNetboxDevicePowerPortRead(d *schema.ResourceData, m interface{}) er } func resourceNetboxDevicePowerPortUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -193,7 +192,7 @@ func resourceNetboxDevicePowerPortUpdate(d *schema.ResourceData, m interface{}) } func resourceNetboxDevicePowerPortDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPowerPortsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_power_port_test.go b/netbox/resource_netbox_device_power_port_test.go index 077530a9..f5b9106a 100644 --- a/netbox/resource_netbox_device_power_port_test.go +++ b/netbox/resource_netbox_device_power_port_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -135,7 +134,7 @@ resource "netbox_device_power_port" "test" { func testAccCheckDevicePowerPortDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each power port // is destroyed @@ -175,7 +174,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimPowerPortsListParams() res, err := api.Dcim.DcimPowerPortsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_primary_ip.go b/netbox/resource_netbox_device_primary_ip.go index a66f9895..0a2e3d25 100644 --- a/netbox/resource_netbox_device_primary_ip.go +++ b/netbox/resource_netbox_device_primary_ip.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -48,7 +47,7 @@ func resourceNetboxDevicePrimaryIPCreate(d *schema.ResourceData, m interface{}) } func resourceNetboxDevicePrimaryIPRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimDevicesReadParams().WithID(id) @@ -82,7 +81,7 @@ func resourceNetboxDevicePrimaryIPRead(d *schema.ResourceData, m interface{}) er } func resourceNetboxDevicePrimaryIPUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient deviceID := int64(d.Get("device_id").(int)) IPAddressID := int64(d.Get("ip_address_id").(int)) diff --git a/netbox/resource_netbox_device_rear_port.go b/netbox/resource_netbox_device_rear_port.go index 5a9aff65..b0dcad00 100644 --- a/netbox/resource_netbox_device_rear_port.go +++ b/netbox/resource_netbox_device_rear_port.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -69,7 +68,7 @@ func resourceNetboxDeviceRearPort() *schema.Resource { } func resourceNetboxDeviceRearPortCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableRearPort{ Device: int64ToPtr(int64(d.Get("device_id").(int))), @@ -103,7 +102,7 @@ func resourceNetboxDeviceRearPortCreate(d *schema.ResourceData, m interface{}) e } func resourceNetboxDeviceRearPortRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRearPortsReadParams().WithID(id) @@ -158,7 +157,7 @@ func resourceNetboxDeviceRearPortRead(d *schema.ResourceData, m interface{}) err } func resourceNetboxDeviceRearPortUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -192,7 +191,7 @@ func resourceNetboxDeviceRearPortUpdate(d *schema.ResourceData, m interface{}) e } func resourceNetboxDeviceRearPortDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRearPortsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_rear_port_test.go b/netbox/resource_netbox_device_rear_port_test.go index cd411852..d1a9f63a 100644 --- a/netbox/resource_netbox_device_rear_port_test.go +++ b/netbox/resource_netbox_device_rear_port_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -140,7 +139,7 @@ resource "netbox_device_rear_port" "test" { func testAccCheckDeviceRearPortDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each rear port // is destroyed @@ -180,7 +179,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimRearPortsListParams() res, err := api.Dcim.DcimRearPortsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_role.go b/netbox/resource_netbox_device_role.go index 8eb1108e..95b75a71 100644 --- a/netbox/resource_netbox_device_role.go +++ b/netbox/resource_netbox_device_role.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -54,7 +53,7 @@ func resourceNetboxDeviceRole() *schema.Resource { } func resourceNetboxDeviceRoleCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) slugValue, slugOk := d.GetOk("slug") @@ -96,7 +95,7 @@ func resourceNetboxDeviceRoleCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxDeviceRoleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimDeviceRolesReadParams().WithID(id) @@ -123,7 +122,7 @@ func resourceNetboxDeviceRoleRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxDeviceRoleUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.DeviceRole{} @@ -163,7 +162,7 @@ func resourceNetboxDeviceRoleUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxDeviceRoleDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimDeviceRolesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_role_test.go b/netbox/resource_netbox_device_role_test.go index f73aa29e..4fbcb3ee 100644 --- a/netbox/resource_netbox_device_role_test.go +++ b/netbox/resource_netbox_device_role_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -74,7 +73,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimDeviceRolesListParams() res, err := api.Dcim.DcimDeviceRolesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_test.go b/netbox/resource_netbox_device_test.go index a8a46abf..1b0d632b 100644 --- a/netbox/resource_netbox_device_test.go +++ b/netbox/resource_netbox_device_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -348,7 +347,7 @@ resource "netbox_device" "test" { func testAccCheckDeviceDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each device // is destroyed @@ -388,7 +387,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimDevicesListParams() res, err := api.Dcim.DcimDevicesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_device_type.go b/netbox/resource_netbox_device_type.go index 6c7fffe1..d9f0bbf9 100644 --- a/netbox/resource_netbox_device_type.go +++ b/netbox/resource_netbox_device_type.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -58,7 +57,7 @@ func resourceNetboxDeviceType() *schema.Resource { } func resourceNetboxDeviceTypeCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableDeviceType{} @@ -105,7 +104,7 @@ func resourceNetboxDeviceTypeCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxDeviceTypeRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimDeviceTypesReadParams().WithID(id) @@ -136,7 +135,7 @@ func resourceNetboxDeviceTypeRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxDeviceTypeUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableDeviceType{} @@ -182,7 +181,7 @@ func resourceNetboxDeviceTypeUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxDeviceTypeDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimDeviceTypesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_device_type_test.go b/netbox/resource_netbox_device_type_test.go index baa13381..9fc030a8 100644 --- a/netbox/resource_netbox_device_type_test.go +++ b/netbox/resource_netbox_device_type_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -83,7 +82,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimDeviceTypesListParams() res, err := api.Dcim.DcimDeviceTypesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_event_rule.go b/netbox/resource_netbox_event_rule.go index 9431401b..df9d9ba5 100644 --- a/netbox/resource_netbox_event_rule.go +++ b/netbox/resource_netbox_event_rule.go @@ -4,7 +4,6 @@ import ( "encoding/json" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -96,7 +95,7 @@ func resourceNetboxEventRule() *schema.Resource { } func resourceNetboxEventRuleCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := &models.WritableEventRule{} @@ -152,7 +151,7 @@ func resourceNetboxEventRuleCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxEventRuleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasEventRulesReadParams().WithID(id) @@ -196,7 +195,7 @@ func resourceNetboxEventRuleRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxEventRuleUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableEventRule{} @@ -251,7 +250,7 @@ func resourceNetboxEventRuleUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxEventRuleDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasEventRulesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_event_rule_test.go b/netbox/resource_netbox_event_rule_test.go index 666a58a7..120fc73e 100644 --- a/netbox/resource_netbox_event_rule_test.go +++ b/netbox/resource_netbox_event_rule_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -88,7 +87,7 @@ resource "netbox_event_rule" "test" { } func testAccCheckNetBoxEventRuleDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*client.NetBoxAPI) + client := testAccProvider.Meta().(*Config).LegacyClient for _, rs := range s.RootModule().Resources { if rs.Type != "netbox_event_rule" { @@ -116,7 +115,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := extras.NewExtrasEventRulesListParams() res, err := api.Extras.ExtrasEventRulesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_group.go b/netbox/resource_netbox_group.go index 828a215c..e285828f 100644 --- a/netbox/resource_netbox_group.go +++ b/netbox/resource_netbox_group.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/users" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -30,7 +29,7 @@ func resourceNetboxGroup() *schema.Resource { } } func resourceNetboxGroupCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.Group{} name := d.Get("name").(string) @@ -48,7 +47,7 @@ func resourceNetboxGroupCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := users.NewUsersGroupsReadParams().WithID(id) @@ -73,7 +72,7 @@ func resourceNetboxGroupRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxGroupUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.Group{} @@ -90,7 +89,7 @@ func resourceNetboxGroupUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxGroupDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := users.NewUsersGroupsDeleteParams().WithID(id) _, err := api.Users.UsersGroupsDelete(params, nil) diff --git a/netbox/resource_netbox_group_test.go b/netbox/resource_netbox_group_test.go index b158a18e..6925588f 100644 --- a/netbox/resource_netbox_group_test.go +++ b/netbox/resource_netbox_group_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/users" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -45,7 +44,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := users.NewUsersGroupsListParams() res, err := api.Users.UsersGroupsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_interface.go b/netbox/resource_netbox_interface.go index e7146c74..a2755eb1 100644 --- a/netbox/resource_netbox_interface.go +++ b/netbox/resource_netbox_interface.go @@ -5,7 +5,6 @@ import ( "strconv" "strings" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -88,7 +87,7 @@ func resourceNetboxInterface() *schema.Resource { } func resourceNetboxInterfaceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient var diags diag.Diagnostics @@ -134,7 +133,7 @@ func resourceNetboxInterfaceCreate(ctx context.Context, d *schema.ResourceData, } func resourceNetboxInterfaceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) var diags diag.Diagnostics @@ -176,7 +175,7 @@ func resourceNetboxInterfaceRead(ctx context.Context, d *schema.ResourceData, m } func resourceNetboxInterfaceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient var diags diag.Diagnostics @@ -226,7 +225,7 @@ func resourceNetboxInterfaceUpdate(ctx context.Context, d *schema.ResourceData, } func resourceNetboxInterfaceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := virtualization.NewVirtualizationInterfacesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_interface_test.go b/netbox/resource_netbox_interface_test.go index b575356e..1a9b9c3e 100644 --- a/netbox/resource_netbox_interface_test.go +++ b/netbox/resource_netbox_interface_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -203,7 +202,7 @@ func TestAccNetboxInterface_vlans(t *testing.T) { func testAccCheckInterfaceDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each interface // is destroyed @@ -243,7 +242,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := virtualization.NewVirtualizationInterfacesListParams() res, err := api.Virtualization.VirtualizationInterfacesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_inventory_item.go b/netbox/resource_netbox_inventory_item.go index 824064c4..04faf640 100644 --- a/netbox/resource_netbox_inventory_item.go +++ b/netbox/resource_netbox_inventory_item.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -95,7 +94,7 @@ func resourceNetboxInventoryItem() *schema.Resource { } func resourceNetboxInventoryItemCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableInventoryItem{ Device: int64ToPtr(int64(d.Get("device_id").(int))), Name: strToPtr(d.Get("name").(string)), @@ -138,7 +137,7 @@ func resourceNetboxInventoryItemCreate(d *schema.ResourceData, m interface{}) er } func resourceNetboxInventoryItemRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimInventoryItemsReadParams().WithID(id) @@ -198,7 +197,7 @@ func resourceNetboxInventoryItemRead(d *schema.ResourceData, m interface{}) erro } func resourceNetboxInventoryItemUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -242,7 +241,7 @@ func resourceNetboxInventoryItemUpdate(d *schema.ResourceData, m interface{}) er } func resourceNetboxInventoryItemDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimInventoryItemsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_inventory_item_role.go b/netbox/resource_netbox_inventory_item_role.go index cb57d95f..ddeac72a 100644 --- a/netbox/resource_netbox_inventory_item_role.go +++ b/netbox/resource_netbox_inventory_item_role.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -49,7 +48,7 @@ func resourceNetboxInventoryItemRole() *schema.Resource { } func resourceNetboxInventoryItemRoleCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.InventoryItemRole{ Name: strToPtr(d.Get("name").(string)), Slug: strToPtr(d.Get("slug").(string)), @@ -77,7 +76,7 @@ func resourceNetboxInventoryItemRoleCreate(d *schema.ResourceData, m interface{} } func resourceNetboxInventoryItemRoleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimInventoryItemRolesReadParams().WithID(id) @@ -109,7 +108,7 @@ func resourceNetboxInventoryItemRoleRead(d *schema.ResourceData, m interface{}) } func resourceNetboxInventoryItemRoleUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -138,7 +137,7 @@ func resourceNetboxInventoryItemRoleUpdate(d *schema.ResourceData, m interface{} } func resourceNetboxInventoryItemRoleDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimInventoryItemRolesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_inventory_item_role_test.go b/netbox/resource_netbox_inventory_item_role_test.go index 11344ec3..616e9caa 100644 --- a/netbox/resource_netbox_inventory_item_role_test.go +++ b/netbox/resource_netbox_inventory_item_role_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -74,7 +73,7 @@ resource "netbox_inventory_item_role" "test" { func testAccCheckInventoryItemRoleDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each inventory item role // is destroyed @@ -114,7 +113,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimInventoryItemRolesListParams() res, err := api.Dcim.DcimInventoryItemRolesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_inventory_item_test.go b/netbox/resource_netbox_inventory_item_test.go index 0376c1f4..cbc03b01 100644 --- a/netbox/resource_netbox_inventory_item_test.go +++ b/netbox/resource_netbox_inventory_item_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -177,7 +176,7 @@ resource "netbox_inventory_item" "test" { func testAccCheckInventoryItemDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each inventory item // is destroyed @@ -217,7 +216,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimInventoryItemsListParams() res, err := api.Dcim.DcimInventoryItemsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_ip_address.go b/netbox/resource_netbox_ip_address.go index bd8d39db..6e5501ac 100644 --- a/netbox/resource_netbox_ip_address.go +++ b/netbox/resource_netbox_ip_address.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -116,7 +115,7 @@ func resourceNetboxIPAddress() *schema.Resource { } func resourceNetboxIPAddressCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableIPAddress{} @@ -166,7 +165,7 @@ func resourceNetboxIPAddressCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxIPAddressRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamIPAddressesReadParams().WithID(id) @@ -259,7 +258,7 @@ func resourceNetboxIPAddressRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxIPAddressUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableIPAddress{} @@ -308,7 +307,7 @@ func resourceNetboxIPAddressUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxIPAddressDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamIPAddressesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_ip_address_test.go b/netbox/resource_netbox_ip_address_test.go index e6c55721..7bb107d6 100644 --- a/netbox/resource_netbox_ip_address_test.go +++ b/netbox/resource_netbox_ip_address_test.go @@ -6,7 +6,6 @@ import ( "regexp" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -493,7 +492,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamIPAddressesListParams() res, err := api.Ipam.IpamIPAddressesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_ip_range.go b/netbox/resource_netbox_ip_range.go index 5cce094f..cdb391f0 100644 --- a/netbox/resource_netbox_ip_range.go +++ b/netbox/resource_netbox_ip_range.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -64,7 +63,7 @@ func resourceNetboxIPRange() *schema.Resource { } func resourceNetboxIPRangeCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableIPRange{} startAddress := d.Get("start_address").(string) @@ -90,7 +89,7 @@ func resourceNetboxIPRangeCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxIPRangeRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamIPRangesReadParams().WithID(id) @@ -141,7 +140,7 @@ func resourceNetboxIPRangeRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxIPRangeUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableIPRange{} startAddress := d.Get("start_address").(string) @@ -178,7 +177,7 @@ func resourceNetboxIPRangeUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxIPRangeDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamIPRangesDeleteParams().WithID(id) _, err := api.Ipam.IpamIPRangesDelete(params, nil) diff --git a/netbox/resource_netbox_ip_range_test.go b/netbox/resource_netbox_ip_range_test.go index 16fea62a..1c66f6ac 100644 --- a/netbox/resource_netbox_ip_range_test.go +++ b/netbox/resource_netbox_ip_range_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -147,7 +146,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamIPRangesListParams() res, err := api.Ipam.IpamIPRangesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_ipam_role.go b/netbox/resource_netbox_ipam_role.go index 56419e1b..78e8b94c 100644 --- a/netbox/resource_netbox_ipam_role.go +++ b/netbox/resource_netbox_ipam_role.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -48,7 +47,7 @@ func resourceNetboxIpamRole() *schema.Resource { } } func resourceNetboxIpamRoleCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.Role{} name := d.Get("name").(string) @@ -81,7 +80,7 @@ func resourceNetboxIpamRoleCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxIpamRoleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamRolesReadParams().WithID(id) @@ -118,7 +117,7 @@ func resourceNetboxIpamRoleRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxIpamRoleUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.Role{} @@ -150,7 +149,7 @@ func resourceNetboxIpamRoleUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxIpamRoleDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamRolesDeleteParams().WithID(id) _, err := api.Ipam.IpamRolesDelete(params, nil) diff --git a/netbox/resource_netbox_ipam_role_test.go b/netbox/resource_netbox_ipam_role_test.go index 5d8d3d5e..736c5255 100644 --- a/netbox/resource_netbox_ipam_role_test.go +++ b/netbox/resource_netbox_ipam_role_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -83,7 +82,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamRolesListParams() res, err := api.Ipam.IpamRolesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_location.go b/netbox/resource_netbox_location.go index 4117b3a4..8c2611a6 100644 --- a/netbox/resource_netbox_location.go +++ b/netbox/resource_netbox_location.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -60,7 +59,7 @@ Each location must have a name that is unique within its parent site and locatio } func resourceNetboxLocationCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableLocation{} @@ -112,7 +111,7 @@ func resourceNetboxLocationCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxLocationRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimLocationsReadParams().WithID(id) @@ -164,7 +163,7 @@ func resourceNetboxLocationRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxLocationUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableLocation{} @@ -218,7 +217,7 @@ func resourceNetboxLocationUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxLocationDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimLocationsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_location_test.go b/netbox/resource_netbox_location_test.go index bffee866..3ff0cf29 100644 --- a/netbox/resource_netbox_location_test.go +++ b/netbox/resource_netbox_location_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -176,7 +175,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimLocationsListParams() res, err := api.Dcim.DcimLocationsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_manufacturer.go b/netbox/resource_netbox_manufacturer.go index 2adfc658..7525705e 100644 --- a/netbox/resource_netbox_manufacturer.go +++ b/netbox/resource_netbox_manufacturer.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -40,7 +39,7 @@ func resourceNetboxManufacturer() *schema.Resource { } func resourceNetboxManufacturerCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.Manufacturer{} @@ -70,7 +69,7 @@ func resourceNetboxManufacturerCreate(d *schema.ResourceData, m interface{}) err } func resourceNetboxManufacturerRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimManufacturersReadParams().WithID(id) @@ -95,7 +94,7 @@ func resourceNetboxManufacturerRead(d *schema.ResourceData, m interface{}) error } func resourceNetboxManufacturerUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.Manufacturer{} @@ -124,7 +123,7 @@ func resourceNetboxManufacturerUpdate(d *schema.ResourceData, m interface{}) err } func resourceNetboxManufacturerDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimManufacturersDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_manufacturer_test.go b/netbox/resource_netbox_manufacturer_test.go index 0c6a2b81..4b1c07c1 100644 --- a/netbox/resource_netbox_manufacturer_test.go +++ b/netbox/resource_netbox_manufacturer_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -48,7 +47,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimManufacturersListParams() res, err := api.Dcim.DcimManufacturersList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_module.go b/netbox/resource_netbox_module.go index ccd7c90d..f4c7bd16 100644 --- a/netbox/resource_netbox_module.go +++ b/netbox/resource_netbox_module.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -68,7 +67,7 @@ Similar to devices, modules are instantiated from module types, and any componen } func resourceNetboxModuleCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableModule{ Device: int64ToPtr(int64(d.Get("device_id").(int))), @@ -104,7 +103,7 @@ func resourceNetboxModuleCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxModuleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimModulesReadParams().WithID(id) @@ -161,7 +160,7 @@ func resourceNetboxModuleRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxModuleUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -197,7 +196,7 @@ func resourceNetboxModuleUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxModuleDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimModulesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_module_test.go b/netbox/resource_netbox_module_test.go index d783f3c9..59d44629 100644 --- a/netbox/resource_netbox_module_test.go +++ b/netbox/resource_netbox_module_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -129,7 +128,7 @@ resource "netbox_module" "test" { func testAccCheckModuleDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each module // is destroyed @@ -169,7 +168,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimModulesListParams() res, err := api.Dcim.DcimModulesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_module_type.go b/netbox/resource_netbox_module_type.go index fa775072..bc107459 100644 --- a/netbox/resource_netbox_module_type.go +++ b/netbox/resource_netbox_module_type.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -63,7 +62,7 @@ func resourceNetboxModuleType() *schema.Resource { } func resourceNetboxModuleTypeCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableModuleType{ Manufacturer: int64ToPtr(int64(d.Get("manufacturer_id").(int))), @@ -95,7 +94,7 @@ func resourceNetboxModuleTypeCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxModuleTypeRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimModuleTypesReadParams().WithID(id) @@ -142,7 +141,7 @@ func resourceNetboxModuleTypeRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxModuleTypeUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -174,7 +173,7 @@ func resourceNetboxModuleTypeUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxModuleTypeDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimModuleTypesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_module_type_test.go b/netbox/resource_netbox_module_type_test.go index 9cc77ebd..b25f3fb4 100644 --- a/netbox/resource_netbox_module_type_test.go +++ b/netbox/resource_netbox_module_type_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -88,7 +87,7 @@ resource "netbox_module_type" "test" { func testAccCheckModuleTypeDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each module type // is destroyed @@ -128,7 +127,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimModuleTypesListParams() res, err := api.Dcim.DcimModuleTypesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_permission.go b/netbox/resource_netbox_permission.go index 42892687..bc10f30f 100644 --- a/netbox/resource_netbox_permission.go +++ b/netbox/resource_netbox_permission.go @@ -4,7 +4,6 @@ import ( "encoding/json" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/users" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -86,7 +85,7 @@ func resourceNetboxPermission() *schema.Resource { } } func resourceNetboxPermissionCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableObjectPermission{} name := d.Get("name").(string) @@ -127,7 +126,7 @@ func resourceNetboxPermissionCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxPermissionRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := users.NewUsersPermissionsReadParams().WithID(id) @@ -178,7 +177,7 @@ func resourceNetboxPermissionRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPermissionUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableObjectPermission{} @@ -217,7 +216,7 @@ func resourceNetboxPermissionUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxPermissionDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := users.NewUsersPermissionsDeleteParams().WithID(id) _, err := api.Users.UsersPermissionsDelete(params, nil) diff --git a/netbox/resource_netbox_permission_test.go b/netbox/resource_netbox_permission_test.go index de2ea77b..0f30f28e 100644 --- a/netbox/resource_netbox_permission_test.go +++ b/netbox/resource_netbox_permission_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/users" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -93,7 +92,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := users.NewUsersPermissionsListParams() res, err := api.Users.UsersPermissionsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_platform.go b/netbox/resource_netbox_platform.go index 16d0dd13..8dcf0b58 100644 --- a/netbox/resource_netbox_platform.go +++ b/netbox/resource_netbox_platform.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -40,7 +39,7 @@ func resourceNetboxPlatform() *schema.Resource { } func resourceNetboxPlatformCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) @@ -73,7 +72,7 @@ func resourceNetboxPlatformCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPlatformRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPlatformsReadParams().WithID(id) @@ -97,7 +96,7 @@ func resourceNetboxPlatformRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPlatformUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritablePlatform{} @@ -128,7 +127,7 @@ func resourceNetboxPlatformUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPlatformDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPlatformsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_platform_test.go b/netbox/resource_netbox_platform_test.go index a8d17b6c..63d74c16 100644 --- a/netbox/resource_netbox_platform_test.go +++ b/netbox/resource_netbox_platform_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -69,7 +68,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimPlatformsListParams() res, err := api.Dcim.DcimPlatformsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_power_panel.go b/netbox/resource_netbox_power_panel.go index 75a0ee4b..9d18ecfc 100644 --- a/netbox/resource_netbox_power_panel.go +++ b/netbox/resource_netbox_power_panel.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -51,7 +50,7 @@ func resourceNetboxPowerPanel() *schema.Resource { } func resourceNetboxPowerPanelCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritablePowerPanel{ Site: int64ToPtr(int64(d.Get("site_id").(int))), @@ -81,7 +80,7 @@ func resourceNetboxPowerPanelCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxPowerPanelRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPowerPanelsReadParams().WithID(id) @@ -126,7 +125,7 @@ func resourceNetboxPowerPanelRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPowerPanelUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -156,7 +155,7 @@ func resourceNetboxPowerPanelUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxPowerPanelDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimPowerPanelsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_power_panel_test.go b/netbox/resource_netbox_power_panel_test.go index fb52377f..1c9a5065 100644 --- a/netbox/resource_netbox_power_panel_test.go +++ b/netbox/resource_netbox_power_panel_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -87,7 +86,7 @@ resource "netbox_power_panel" "test" { func testAccCheckPowerPanelDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each power panel // is destroyed @@ -127,7 +126,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimPowerPanelsListParams() res, err := api.Dcim.DcimPowerPanelsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_prefix.go b/netbox/resource_netbox_prefix.go index b7621f30..df3aba8d 100644 --- a/netbox/resource_netbox_prefix.go +++ b/netbox/resource_netbox_prefix.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -78,7 +77,7 @@ func resourceNetboxPrefix() *schema.Resource { } } func resourceNetboxPrefixCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritablePrefix{} prefix := d.Get("prefix").(string) @@ -133,7 +132,7 @@ func resourceNetboxPrefixCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPrefixRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamPrefixesReadParams().WithID(id) @@ -202,7 +201,7 @@ func resourceNetboxPrefixRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPrefixUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritablePrefix{} prefix := d.Get("prefix").(string) @@ -257,7 +256,7 @@ func resourceNetboxPrefixUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPrefixDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamPrefixesDeleteParams().WithID(id) _, err := api.Ipam.IpamPrefixesDelete(params, nil) diff --git a/netbox/resource_netbox_prefix_test.go b/netbox/resource_netbox_prefix_test.go index b715560e..a37a21b8 100644 --- a/netbox/resource_netbox_prefix_test.go +++ b/netbox/resource_netbox_prefix_test.go @@ -6,7 +6,6 @@ import ( "regexp" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -272,7 +271,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamPrefixesListParams() res, err := api.Ipam.IpamPrefixesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_primary_ip.go b/netbox/resource_netbox_primary_ip.go index 68c8d7f6..eaa5ee14 100644 --- a/netbox/resource_netbox_primary_ip.go +++ b/netbox/resource_netbox_primary_ip.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -48,7 +47,7 @@ func resourceNetboxPrimaryIPCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxPrimaryIPRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := virtualization.NewVirtualizationVirtualMachinesReadParams().WithID(id) @@ -82,7 +81,7 @@ func resourceNetboxPrimaryIPRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxPrimaryIPUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient virtualMachineID := int64(d.Get("virtual_machine_id").(int)) IPAddressID := int64(d.Get("ip_address_id").(int)) diff --git a/netbox/resource_netbox_rack.go b/netbox/resource_netbox_rack.go index d41d0c52..74413d13 100644 --- a/netbox/resource_netbox_rack.go +++ b/netbox/resource_netbox_rack.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -152,7 +151,7 @@ Each rack is assigned a name and (optionally) a separate facility ID. This is he } func resourceNetboxRackCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) siteID := int64(d.Get("site_id").(int)) @@ -214,7 +213,7 @@ func resourceNetboxRackCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRackRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRacksReadParams().WithID(id) @@ -318,7 +317,7 @@ func resourceNetboxRackRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRackUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -382,7 +381,7 @@ func resourceNetboxRackUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRackDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRacksDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_rack_reservation.go b/netbox/resource_netbox_rack_reservation.go index 6b3af09b..52d3abc0 100644 --- a/netbox/resource_netbox_rack_reservation.go +++ b/netbox/resource_netbox_rack_reservation.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -58,7 +57,7 @@ func resourceNetboxRackReservation() *schema.Resource { } func resourceNetboxRackReservationCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient tags, _ := getNestedTagListFromResourceDataSet(api, d.Get(tagsKey)) @@ -85,7 +84,7 @@ func resourceNetboxRackReservationCreate(d *schema.ResourceData, m interface{}) } func resourceNetboxRackReservationRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRackReservationsReadParams().WithID(id) @@ -131,7 +130,7 @@ func resourceNetboxRackReservationRead(d *schema.ResourceData, m interface{}) er } func resourceNetboxRackReservationUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -158,7 +157,7 @@ func resourceNetboxRackReservationUpdate(d *schema.ResourceData, m interface{}) } func resourceNetboxRackReservationDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRackReservationsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_rack_reservation_test.go b/netbox/resource_netbox_rack_reservation_test.go index d3a618ab..5f4c4895 100644 --- a/netbox/resource_netbox_rack_reservation_test.go +++ b/netbox/resource_netbox_rack_reservation_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -73,7 +72,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimRackReservationsListParams() res, err := api.Dcim.DcimRackReservationsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_rack_role.go b/netbox/resource_netbox_rack_role.go index 1621b8ad..da08bb5a 100644 --- a/netbox/resource_netbox_rack_role.go +++ b/netbox/resource_netbox_rack_role.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -49,7 +48,7 @@ func resourceNetboxRackRole() *schema.Resource { } func resourceNetboxRackRoleCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) slugValue, slugOk := d.GetOk("slug") @@ -88,7 +87,7 @@ func resourceNetboxRackRoleCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRackRoleRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRackRolesReadParams().WithID(id) @@ -116,7 +115,7 @@ func resourceNetboxRackRoleRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRackRoleUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.RackRole{} @@ -153,7 +152,7 @@ func resourceNetboxRackRoleUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRackRoleDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRackRolesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_rack_role_test.go b/netbox/resource_netbox_rack_role_test.go index 5c7659c5..1edfa31a 100644 --- a/netbox/resource_netbox_rack_role_test.go +++ b/netbox/resource_netbox_rack_role_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -72,7 +71,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimRackRolesListParams() res, err := api.Dcim.DcimRackRolesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_rack_test.go b/netbox/resource_netbox_rack_test.go index 5577d405..9129e416 100644 --- a/netbox/resource_netbox_rack_test.go +++ b/netbox/resource_netbox_rack_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -153,7 +152,7 @@ resource "netbox_rack" "test" { func testAccCheckRackDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each rack // is destroyed @@ -193,7 +192,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimRacksListParams() res, err := api.Dcim.DcimRacksList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_region.go b/netbox/resource_netbox_region.go index 56bdc64f..2285dd3c 100644 --- a/netbox/resource_netbox_region.go +++ b/netbox/resource_netbox_region.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -55,7 +54,7 @@ func resourceNetboxRegion() *schema.Resource { } func resourceNetboxRegionCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableRegion{} @@ -93,7 +92,7 @@ func resourceNetboxRegionCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRegionRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRegionsReadParams().WithID(id) @@ -123,7 +122,7 @@ func resourceNetboxRegionRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRegionUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableRegion{} @@ -161,7 +160,7 @@ func resourceNetboxRegionUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRegionDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimRegionsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_region_test.go b/netbox/resource_netbox_region_test.go index a81c5b11..1c01dc47 100644 --- a/netbox/resource_netbox_region_test.go +++ b/netbox/resource_netbox_region_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -72,7 +71,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimRegionsListParams() res, err := api.Dcim.DcimRegionsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_rir.go b/netbox/resource_netbox_rir.go index 4d7bc2a9..0a4f2785 100644 --- a/netbox/resource_netbox_rir.go +++ b/netbox/resource_netbox_rir.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -49,7 +48,7 @@ func resourceNetboxRir() *schema.Resource { } func resourceNetboxRirCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.RIR{} name := d.Get("name").(string) @@ -79,7 +78,7 @@ func resourceNetboxRirCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRirRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamRirsReadParams().WithID(id) @@ -107,7 +106,7 @@ func resourceNetboxRirRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRirUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.RIR{} @@ -136,7 +135,7 @@ func resourceNetboxRirUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxRirDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamRirsDeleteParams().WithID(id) _, err := api.Ipam.IpamRirsDelete(params, nil) diff --git a/netbox/resource_netbox_rir_test.go b/netbox/resource_netbox_rir_test.go index 10bf1f54..c77c298e 100644 --- a/netbox/resource_netbox_rir_test.go +++ b/netbox/resource_netbox_rir_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -101,7 +100,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamRirsListParams() res, err := api.Ipam.IpamRirsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_route_target.go b/netbox/resource_netbox_route_target.go index 1006b7ee..0d66c077 100644 --- a/netbox/resource_netbox_route_target.go +++ b/netbox/resource_netbox_route_target.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -44,7 +43,7 @@ func resourceNetboxRouteTarget() *schema.Resource { } } func resourceNetboxRouteTargetCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableRouteTarget{} name := d.Get("name").(string) @@ -63,7 +62,7 @@ func resourceNetboxRouteTargetCreate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxRouteTargetRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamRouteTargetsReadParams().WithID(id) @@ -100,7 +99,7 @@ func resourceNetboxRouteTargetRead(d *schema.ResourceData, m interface{}) error } func resourceNetboxRouteTargetUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableRouteTarget{} @@ -122,7 +121,7 @@ func resourceNetboxRouteTargetUpdate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxRouteTargetDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamRouteTargetsDeleteParams().WithID(id) _, err := api.Ipam.IpamRouteTargetsDelete(params, nil) diff --git a/netbox/resource_netbox_route_target_test.go b/netbox/resource_netbox_route_target_test.go index f7fb294b..8070b896 100644 --- a/netbox/resource_netbox_route_target_test.go +++ b/netbox/resource_netbox_route_target_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" log "github.com/sirupsen/logrus" @@ -89,7 +88,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamRouteTargetsListParams() res, err := api.Ipam.IpamRouteTargetsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_service.go b/netbox/resource_netbox_service.go index c4cceed9..1e487b94 100644 --- a/netbox/resource_netbox_service.go +++ b/netbox/resource_netbox_service.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -63,7 +62,7 @@ func resourceNetboxService() *schema.Resource { } } func resourceNetboxServiceCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableService{} dataName := d.Get("name").(string) @@ -111,7 +110,7 @@ func resourceNetboxServiceCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxServiceRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamServicesReadParams().WithID(id) @@ -142,7 +141,7 @@ func resourceNetboxServiceRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxServiceUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableService{} @@ -186,7 +185,7 @@ func resourceNetboxServiceUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxServiceDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamServicesDeleteParams().WithID(id) _, err := api.Ipam.IpamServicesDelete(params, nil) diff --git a/netbox/resource_netbox_service_test.go b/netbox/resource_netbox_service_test.go index 5f346072..d499e8cd 100644 --- a/netbox/resource_netbox_service_test.go +++ b/netbox/resource_netbox_service_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -107,7 +106,7 @@ resource "netbox_service" "test_customfield" { func testAccCheckServiceDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each service // is destroyed @@ -147,7 +146,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamServicesListParams() res, err := api.Ipam.IpamServicesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_site.go b/netbox/resource_netbox_site.go index 62b8432a..426aa449 100644 --- a/netbox/resource_netbox_site.go +++ b/netbox/resource_netbox_site.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -104,7 +103,7 @@ func resourceNetboxSite() *schema.Resource { } func resourceNetboxSiteCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableSite{} @@ -193,7 +192,7 @@ func resourceNetboxSiteCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxSiteRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimSitesReadParams().WithID(id) @@ -253,7 +252,7 @@ func resourceNetboxSiteRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxSiteUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableSite{} @@ -350,7 +349,7 @@ func resourceNetboxSiteUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxSiteDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimSitesDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_site_group.go b/netbox/resource_netbox_site_group.go index 1d2e2f31..78fec7ec 100644 --- a/netbox/resource_netbox_site_group.go +++ b/netbox/resource_netbox_site_group.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -50,7 +49,7 @@ func resourceNetboxSiteGroup() *schema.Resource { } func resourceNetboxSiteGroupCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) parentID := int64(d.Get("parent_id").(int)) @@ -88,7 +87,7 @@ func resourceNetboxSiteGroupCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxSiteGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimSiteGroupsReadParams().WithID(id) @@ -117,7 +116,7 @@ func resourceNetboxSiteGroupRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxSiteGroupUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableSiteGroup{} @@ -154,7 +153,7 @@ func resourceNetboxSiteGroupUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxSiteGroupDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimSiteGroupsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_site_group_test.go b/netbox/resource_netbox_site_group_test.go index ede42c12..9d941d6f 100644 --- a/netbox/resource_netbox_site_group_test.go +++ b/netbox/resource_netbox_site_group_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -81,7 +80,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimSiteGroupsListParams() res, err := api.Dcim.DcimSiteGroupsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_site_test.go b/netbox/resource_netbox_site_test.go index 4e312ce8..6ab891c0 100644 --- a/netbox/resource_netbox_site_test.go +++ b/netbox/resource_netbox_site_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -186,7 +185,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := dcim.NewDcimSitesListParams() res, err := api.Dcim.DcimSitesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_tag.go b/netbox/resource_netbox_tag.go index 79435871..1c455fab 100644 --- a/netbox/resource_netbox_tag.go +++ b/netbox/resource_netbox_tag.go @@ -4,7 +4,6 @@ import ( "regexp" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -53,7 +52,7 @@ func resourceNetboxTag() *schema.Resource { } func resourceNetboxTagCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) @@ -89,7 +88,7 @@ func resourceNetboxTagCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxTagRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasTagsReadParams().WithID(id) @@ -114,7 +113,7 @@ func resourceNetboxTagRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxTagUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.Tag{} @@ -148,7 +147,7 @@ func resourceNetboxTagUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxTagDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasTagsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_tag_test.go b/netbox/resource_netbox_tag_test.go index a2d96973..65899821 100644 --- a/netbox/resource_netbox_tag_test.go +++ b/netbox/resource_netbox_tag_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -73,7 +72,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := extras.NewExtrasTagsListParams() res, err := api.Extras.ExtrasTagsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_tenant.go b/netbox/resource_netbox_tenant.go index 1ec0139b..e10f7d33 100644 --- a/netbox/resource_netbox_tenant.go +++ b/netbox/resource_netbox_tenant.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -51,7 +50,7 @@ func resourceNetboxTenant() *schema.Resource { } func resourceNetboxTenantCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) groupID := int64(d.Get("group_id").(int)) @@ -92,7 +91,7 @@ func resourceNetboxTenantCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxTenantRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyTenantsReadParams().WithID(id) @@ -120,7 +119,7 @@ func resourceNetboxTenantRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxTenantUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableTenant{} @@ -158,7 +157,7 @@ func resourceNetboxTenantUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxTenantDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyTenantsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_tenant_group.go b/netbox/resource_netbox_tenant_group.go index 66bcfe7d..3ef745e8 100644 --- a/netbox/resource_netbox_tenant_group.go +++ b/netbox/resource_netbox_tenant_group.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -50,7 +49,7 @@ func resourceNetboxTenantGroup() *schema.Resource { } func resourceNetboxTenantGroupCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) parentID := int64(d.Get("parent_id").(int)) @@ -88,7 +87,7 @@ func resourceNetboxTenantGroupCreate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxTenantGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyTenantGroupsReadParams().WithID(id) @@ -116,7 +115,7 @@ func resourceNetboxTenantGroupRead(d *schema.ResourceData, m interface{}) error } func resourceNetboxTenantGroupUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableTenantGroup{} @@ -153,7 +152,7 @@ func resourceNetboxTenantGroupUpdate(d *schema.ResourceData, m interface{}) erro } func resourceNetboxTenantGroupDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := tenancy.NewTenancyTenantGroupsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_tenant_group_test.go b/netbox/resource_netbox_tenant_group_test.go index f5a0db18..3e34c51b 100644 --- a/netbox/resource_netbox_tenant_group_test.go +++ b/netbox/resource_netbox_tenant_group_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -69,7 +68,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyTenantGroupsListParams() res, err := api.Tenancy.TenancyTenantGroupsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_tenant_test.go b/netbox/resource_netbox_tenant_test.go index dac59b8a..21bccec9 100644 --- a/netbox/resource_netbox_tenant_test.go +++ b/netbox/resource_netbox_tenant_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/tenancy" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -128,7 +127,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := tenancy.NewTenancyTenantsListParams() res, err := api.Tenancy.TenancyTenantsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_token.go b/netbox/resource_netbox_token.go index 6a640b8b..fafa7c4f 100644 --- a/netbox/resource_netbox_token.go +++ b/netbox/resource_netbox_token.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/users" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -64,7 +63,7 @@ func resourceNetboxToken() *schema.Resource { } func resourceNetboxTokenCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableToken{} userid := int64(d.Get("user_id").(int)) @@ -94,7 +93,7 @@ func resourceNetboxTokenCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxTokenRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := users.NewUsersTokensReadParams().WithID(id) @@ -127,7 +126,7 @@ func resourceNetboxTokenRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxTokenUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableToken{} @@ -155,7 +154,7 @@ func resourceNetboxTokenUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxTokenDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := users.NewUsersTokensDeleteParams().WithID(id) _, err := api.Users.UsersTokensDelete(params, nil) diff --git a/netbox/resource_netbox_token_test.go b/netbox/resource_netbox_token_test.go index c0d64633..57b19898 100644 --- a/netbox/resource_netbox_token_test.go +++ b/netbox/resource_netbox_token_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/users" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -59,7 +58,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := users.NewUsersUsersListParams() res, err := api.Users.UsersUsersList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_user.go b/netbox/resource_netbox_user.go index 622d22fd..30492924 100644 --- a/netbox/resource_netbox_user.go +++ b/netbox/resource_netbox_user.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/users" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -52,7 +51,7 @@ func resourceNetboxUser() *schema.Resource { } } func resourceNetboxUserCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableUser{} username := d.Get("username").(string) @@ -78,7 +77,7 @@ func resourceNetboxUserCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxUserRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := users.NewUsersUsersReadParams().WithID(id) @@ -109,7 +108,7 @@ func resourceNetboxUserRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxUserUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableUser{} @@ -134,7 +133,7 @@ func resourceNetboxUserUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxUserDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := users.NewUsersUsersDeleteParams().WithID(id) _, err := api.Users.UsersUsersDelete(params, nil) diff --git a/netbox/resource_netbox_user_test.go b/netbox/resource_netbox_user_test.go index 34efe95a..7b325a54 100644 --- a/netbox/resource_netbox_user_test.go +++ b/netbox/resource_netbox_user_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/users" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -86,7 +85,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := users.NewUsersUsersListParams() res, err := api.Users.UsersUsersList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_virtual_chassis.go b/netbox/resource_netbox_virtual_chassis.go index bde25eea..afa50d68 100644 --- a/netbox/resource_netbox_virtual_chassis.go +++ b/netbox/resource_netbox_virtual_chassis.go @@ -48,7 +48,7 @@ func resourceNetboxVirtualChassis() *schema.Resource { } func resourceNetboxVirtualChassisCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) @@ -94,7 +94,7 @@ func resourceNetboxVirtualChassisCreate(ctx context.Context, d *schema.ResourceD } func resourceNetboxVirtualChassisRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -129,7 +129,7 @@ func resourceNetboxVirtualChassisRead(ctx context.Context, d *schema.ResourceDat } func resourceNetboxVirtualChassisUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableVirtualChassis{} @@ -178,7 +178,7 @@ func resourceNetboxVirtualChassisUpdate(ctx context.Context, d *schema.ResourceD } func resourceNetboxVirtualChassisDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := dcim.NewDcimVirtualChassisDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_virtual_chassis_test.go b/netbox/resource_netbox_virtual_chassis_test.go index a4d78a9b..b643a8e0 100644 --- a/netbox/resource_netbox_virtual_chassis_test.go +++ b/netbox/resource_netbox_virtual_chassis_test.go @@ -5,7 +5,6 @@ import ( "strconv" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/dcim" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -60,7 +59,7 @@ resource "netbox_virtual_chassis" "test" { } func testAccCheckVirtualChassisDestroy(s *terraform.State) error { - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each virtual machine // is destroyed diff --git a/netbox/resource_netbox_virtual_disk.go b/netbox/resource_netbox_virtual_disk.go index 44b3c653..04622a99 100644 --- a/netbox/resource_netbox_virtual_disk.go +++ b/netbox/resource_netbox_virtual_disk.go @@ -4,7 +4,6 @@ import ( "context" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -48,7 +47,7 @@ func resourceNetboxVirtualDisks() *schema.Resource { } func resourceNetboxVirtualDisksCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) size := d.Get("size_gb").(int) @@ -86,7 +85,7 @@ func resourceNetboxVirtualDisksCreate(ctx context.Context, d *schema.ResourceDat } func resourceNetboxVirtualDisksRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) @@ -126,7 +125,7 @@ func resourceNetboxVirtualDisksRead(ctx context.Context, d *schema.ResourceData, } func resourceNetboxVirtualDisksUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableVirtualDisk{} @@ -166,7 +165,7 @@ func resourceNetboxVirtualDisksUpdate(ctx context.Context, d *schema.ResourceDat } func resourceNetboxVirtualDisksDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := virtualization.NewVirtualizationVirtualDisksDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_virtual_disk_test.go b/netbox/resource_netbox_virtual_disk_test.go index 77a6702b..07216be7 100644 --- a/netbox/resource_netbox_virtual_disk_test.go +++ b/netbox/resource_netbox_virtual_disk_test.go @@ -5,7 +5,6 @@ import ( "strconv" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -76,7 +75,7 @@ resource "netbox_virtual_disk" "test" { } func testAccCheckVirtualDiskDestroy(s *terraform.State) error { - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each virtual machine // is destroyed diff --git a/netbox/resource_netbox_virtual_machine.go b/netbox/resource_netbox_virtual_machine.go index 2d1ae4c7..84e81f72 100644 --- a/netbox/resource_netbox_virtual_machine.go +++ b/netbox/resource_netbox_virtual_machine.go @@ -5,7 +5,6 @@ import ( "encoding/json" "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -116,7 +115,7 @@ func resourceNetboxVirtualMachine() *schema.Resource { } func resourceNetboxVirtualMachineCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient name := d.Get("name").(string) @@ -212,7 +211,7 @@ func resourceNetboxVirtualMachineCreate(ctx context.Context, d *schema.ResourceD } func resourceNetboxVirtualMachineRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient var diags diag.Diagnostics @@ -325,7 +324,7 @@ func resourceNetboxVirtualMachineRead(ctx context.Context, d *schema.ResourceDat } func resourceNetboxVirtualMachineUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableVirtualMachineWithConfigContext{} @@ -449,7 +448,7 @@ func resourceNetboxVirtualMachineUpdate(ctx context.Context, d *schema.ResourceD } func resourceNetboxVirtualMachineDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient var diags diag.Diagnostics diff --git a/netbox/resource_netbox_virtual_machine_test.go b/netbox/resource_netbox_virtual_machine_test.go index 4d6746bc..89210e85 100644 --- a/netbox/resource_netbox_virtual_machine_test.go +++ b/netbox/resource_netbox_virtual_machine_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/virtualization" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -322,7 +321,7 @@ resource "netbox_virtual_machine" "test" { func testAccCheckVirtualMachineDestroy(s *terraform.State) error { // retrieve the connection established in Provider configuration - conn := testAccProvider.Meta().(*client.NetBoxAPI) + conn := testAccProvider.Meta().(*Config).LegacyClient // loop through the resources in state, verifying each virtual machine // is destroyed @@ -545,7 +544,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := virtualization.NewVirtualizationVirtualMachinesListParams() res, err := api.Virtualization.VirtualizationVirtualMachinesList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_vlan.go b/netbox/resource_netbox_vlan.go index 55a4d225..cba63f59 100644 --- a/netbox/resource_netbox_vlan.go +++ b/netbox/resource_netbox_vlan.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -71,7 +70,7 @@ func resourceNetboxVlan() *schema.Resource { } func resourceNetboxVlanCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableVLAN{} name := d.Get("name").(string) @@ -113,7 +112,7 @@ func resourceNetboxVlanCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxVlanRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamVlansReadParams().WithID(id) @@ -157,7 +156,7 @@ func resourceNetboxVlanRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxVlanUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableVLAN{} name := d.Get("name").(string) @@ -197,7 +196,7 @@ func resourceNetboxVlanUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxVlanDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamVlansDeleteParams().WithID(id) _, err := api.Ipam.IpamVlansDelete(params, nil) diff --git a/netbox/resource_netbox_vlan_group.go b/netbox/resource_netbox_vlan_group.go index ddfa8488..6a721ce4 100644 --- a/netbox/resource_netbox_vlan_group.go +++ b/netbox/resource_netbox_vlan_group.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -68,7 +67,7 @@ func resourceNetboxVlanGroup() *schema.Resource { } func resourceNetboxVlanGroupCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.VLANGroup{} name := d.Get("name").(string) @@ -104,7 +103,7 @@ func resourceNetboxVlanGroupCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxVlanGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamVlanGroupsReadParams().WithID(id) @@ -142,7 +141,7 @@ func resourceNetboxVlanGroupRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxVlanGroupUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.VLANGroup{} @@ -177,7 +176,7 @@ func resourceNetboxVlanGroupUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxVlanGroupDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamVlanGroupsDeleteParams().WithID(id) _, err := api.Ipam.IpamVlanGroupsDelete(params, nil) diff --git a/netbox/resource_netbox_vlan_group_test.go b/netbox/resource_netbox_vlan_group_test.go index d9de516a..7012a678 100644 --- a/netbox/resource_netbox_vlan_group_test.go +++ b/netbox/resource_netbox_vlan_group_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -111,7 +110,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamVlanGroupsListParams() res, err := api.Ipam.IpamVlanGroupsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_vlan_test.go b/netbox/resource_netbox_vlan_test.go index 6f7fb326..2b65d34e 100644 --- a/netbox/resource_netbox_vlan_test.go +++ b/netbox/resource_netbox_vlan_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -119,7 +118,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamVlansListParams() res, err := api.Ipam.IpamVlansList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_vpn_tunnel.go b/netbox/resource_netbox_vpn_tunnel.go index 7cf30acc..d3df0ee1 100644 --- a/netbox/resource_netbox_vpn_tunnel.go +++ b/netbox/resource_netbox_vpn_tunnel.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/vpn" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -63,7 +62,7 @@ func resourceNetboxVpnTunnel() *schema.Resource { } func resourceNetboxVpnTunnelCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableTunnel{} @@ -93,7 +92,7 @@ func resourceNetboxVpnTunnelCreate(d *schema.ResourceData, m interface{}) error } func resourceNetboxVpnTunnelRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := vpn.NewVpnTunnelsReadParams().WithID(id) @@ -136,7 +135,7 @@ func resourceNetboxVpnTunnelRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxVpnTunnelUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableTunnel{} @@ -164,7 +163,7 @@ func resourceNetboxVpnTunnelUpdate(d *schema.ResourceData, m interface{}) error } func resourceNetboxVpnTunnelDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := vpn.NewVpnTunnelsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_vpn_tunnel_group.go b/netbox/resource_netbox_vpn_tunnel_group.go index 71016838..14fafce3 100644 --- a/netbox/resource_netbox_vpn_tunnel_group.go +++ b/netbox/resource_netbox_vpn_tunnel_group.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/vpn" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -44,7 +43,7 @@ func resourceNetboxVpnTunnelGroup() *schema.Resource { } func resourceNetboxVpnTunnelGroupCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.TunnelGroup{} @@ -80,7 +79,7 @@ func resourceNetboxVpnTunnelGroupCreate(d *schema.ResourceData, m interface{}) e } func resourceNetboxVpnTunnelGroupRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := vpn.NewVpnTunnelGroupsReadParams().WithID(id) @@ -104,7 +103,7 @@ func resourceNetboxVpnTunnelGroupRead(d *schema.ResourceData, m interface{}) err } func resourceNetboxVpnTunnelGroupUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.TunnelGroup{} @@ -144,7 +143,7 @@ func resourceNetboxVpnTunnelGroupUpdate(d *schema.ResourceData, m interface{}) e } func resourceNetboxVpnTunnelGroupDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := vpn.NewVpnTunnelGroupsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_vpn_tunnel_group_test.go b/netbox/resource_netbox_vpn_tunnel_group_test.go index 740ffa9b..a89ba987 100644 --- a/netbox/resource_netbox_vpn_tunnel_group_test.go +++ b/netbox/resource_netbox_vpn_tunnel_group_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/vpn" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -49,7 +48,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := vpn.NewVpnTunnelGroupsListParams() res, err := api.Vpn.VpnTunnelGroupsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_vpn_tunnel_termination.go b/netbox/resource_netbox_vpn_tunnel_termination.go index 5be691e2..507189b5 100644 --- a/netbox/resource_netbox_vpn_tunnel_termination.go +++ b/netbox/resource_netbox_vpn_tunnel_termination.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/vpn" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -55,7 +54,7 @@ func resourceNetboxVpnTunnelTermination() *schema.Resource { } func resourceNetboxVpnTunnelTerminationCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableTunnelTermination{} @@ -95,7 +94,7 @@ func resourceNetboxVpnTunnelTerminationCreate(d *schema.ResourceData, m interfac } func resourceNetboxVpnTunnelTerminationRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := vpn.NewVpnTunnelTerminationsReadParams().WithID(id) @@ -135,7 +134,7 @@ func resourceNetboxVpnTunnelTerminationRead(d *schema.ResourceData, m interface{ } func resourceNetboxVpnTunnelTerminationUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableTunnelTermination{} @@ -171,7 +170,7 @@ func resourceNetboxVpnTunnelTerminationUpdate(d *schema.ResourceData, m interfac } func resourceNetboxVpnTunnelTerminationDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := vpn.NewVpnTunnelTerminationsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_vpn_tunnel_termination_test.go b/netbox/resource_netbox_vpn_tunnel_termination_test.go index 11582086..a65f8b5f 100644 --- a/netbox/resource_netbox_vpn_tunnel_termination_test.go +++ b/netbox/resource_netbox_vpn_tunnel_termination_test.go @@ -5,7 +5,6 @@ import ( "log" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/vpn" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -128,7 +127,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := vpn.NewVpnTunnelTerminationsListParams() res, err := api.Vpn.VpnTunnelTerminationsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_vpn_tunnel_test.go b/netbox/resource_netbox_vpn_tunnel_test.go index 9e5e9de2..593ee589 100644 --- a/netbox/resource_netbox_vpn_tunnel_test.go +++ b/netbox/resource_netbox_vpn_tunnel_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/vpn" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -69,7 +68,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := vpn.NewVpnTunnelsListParams() res, err := api.Vpn.VpnTunnelsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_vrf.go b/netbox/resource_netbox_vrf.go index a20ee1d9..14342b47 100644 --- a/netbox/resource_netbox_vrf.go +++ b/netbox/resource_netbox_vrf.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -54,7 +53,7 @@ func resourceNetboxVrf() *schema.Resource { } func resourceNetboxVrfCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := models.WritableVRF{} name := d.Get("name").(string) @@ -91,7 +90,7 @@ func resourceNetboxVrfCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxVrfRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamVrfsReadParams().WithID(id) @@ -126,7 +125,7 @@ func resourceNetboxVrfRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxVrfUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.WritableVRF{} @@ -161,7 +160,7 @@ func resourceNetboxVrfUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxVrfDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := ipam.NewIpamVrfsDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_vrf_test.go b/netbox/resource_netbox_vrf_test.go index b1939464..50d9087d 100644 --- a/netbox/resource_netbox_vrf_test.go +++ b/netbox/resource_netbox_vrf_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/ipam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -207,7 +206,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := ipam.NewIpamVrfsListParams() res, err := api.Ipam.IpamVrfsList(params, nil) if err != nil { diff --git a/netbox/resource_netbox_webhook.go b/netbox/resource_netbox_webhook.go index 34c2c7d6..d73cd6e1 100644 --- a/netbox/resource_netbox_webhook.go +++ b/netbox/resource_netbox_webhook.go @@ -3,7 +3,6 @@ package netbox import ( "strconv" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/fbreckle/go-netbox/netbox/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -66,7 +65,7 @@ func resourceNetboxWebhook() *schema.Resource { } func resourceNetboxWebhookCreate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient data := &models.Webhook{} name := d.Get("name").(string) @@ -92,7 +91,7 @@ func resourceNetboxWebhookCreate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxWebhookRead(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasWebhooksReadParams().WithID(id) @@ -120,7 +119,7 @@ func resourceNetboxWebhookRead(d *schema.ResourceData, m interface{}) error { } func resourceNetboxWebhookUpdate(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) data := models.Webhook{} @@ -147,7 +146,7 @@ func resourceNetboxWebhookUpdate(d *schema.ResourceData, m interface{}) error { } func resourceNetboxWebhookDelete(d *schema.ResourceData, m interface{}) error { - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient id, _ := strconv.ParseInt(d.Id(), 10, 64) params := extras.NewExtrasWebhooksDeleteParams().WithID(id) diff --git a/netbox/resource_netbox_webhook_test.go b/netbox/resource_netbox_webhook_test.go index f380c6e1..bc25f0f1 100644 --- a/netbox/resource_netbox_webhook_test.go +++ b/netbox/resource_netbox_webhook_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "github.com/fbreckle/go-netbox/netbox/client" "github.com/fbreckle/go-netbox/netbox/client/extras" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -124,7 +123,7 @@ resource "netbox_webhook" "test" { } func testAccCheckNetBoxWebhookDestroy(s *terraform.State) error { - client := testAccProvider.Meta().(*client.NetBoxAPI) + client := testAccProvider.Meta().(*Config).LegacyClient for _, rs := range s.RootModule().Resources { if rs.Type != "netbox_webhook" { @@ -152,7 +151,7 @@ func init() { if err != nil { return fmt.Errorf("Error getting client: %s", err) } - api := m.(*client.NetBoxAPI) + api := m.(*Config).LegacyClient params := extras.NewExtrasWebhooksListParams() res, err := api.Extras.ExtrasWebhooksList(params, nil) if err != nil { diff --git a/tools/tools.go b/tools/tools.go index 858a4f9c..6e409600 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,3 +1,4 @@ +//go:build tools // +build tools package tools