Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions netbox/resource_netbox_cable.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,12 @@ func resourceNetboxCableRead(d *schema.ResourceData, m interface{}) error {
res, err := api.Dcim.DcimCablesRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimCablesReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimCablesReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_config_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,12 @@ func resourceNetboxConfigContextRead(d *schema.ResourceData, m interface{}) erro
res, err := api.Extras.ExtrasConfigContextsRead(params, nil)

if err != nil {
errorcode := err.(*extras.ExtrasConfigContextsReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*extras.ExtrasConfigContextsReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_device_bay.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ func resourceNetboxDeviceBayRead(d *schema.ResourceData, m interface{}) error {
res, err := api.Dcim.DcimDeviceBaysRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimDeviceBaysReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimDeviceBaysReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_device_front_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ func resourceNetboxDeviceFrontPortRead(d *schema.ResourceData, m interface{}) er
res, err := api.Dcim.DcimFrontPortsRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimFrontPortsReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimFrontPortsReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_device_module_bay.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ func resourceNetboxDeviceModuleBayRead(d *schema.ResourceData, m interface{}) er
res, err := api.Dcim.DcimModuleBaysRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimModuleBaysReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimModuleBaysReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_device_power_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ func resourceNetboxPowerFeedRead(d *schema.ResourceData, m interface{}) error {
res, err := api.Dcim.DcimPowerFeedsRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimPowerFeedsReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimPowerFeedsReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_device_power_outlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ func resourceNetboxDevicePowerOutletRead(d *schema.ResourceData, m interface{})
res, err := api.Dcim.DcimPowerOutletsRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimPowerOutletsReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimPowerOutletsReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_device_power_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ func resourceNetboxDevicePowerPortRead(d *schema.ResourceData, m interface{}) er
res, err := api.Dcim.DcimPowerPortsRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimPowerPortsReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimPowerPortsReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_device_rear_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ func resourceNetboxDeviceRearPortRead(d *schema.ResourceData, m interface{}) err
res, err := api.Dcim.DcimRearPortsRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimRearPortsReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimRearPortsReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_inventory_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ func resourceNetboxInventoryItemRead(d *schema.ResourceData, m interface{}) erro
res, err := api.Dcim.DcimInventoryItemsRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimInventoryItemsReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimInventoryItemsReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_inventory_item_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ func resourceNetboxInventoryItemRoleRead(d *schema.ResourceData, m interface{})
res, err := api.Dcim.DcimInventoryItemRolesRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimInventoryItemRolesReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimInventoryItemRolesReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ func resourceNetboxModuleRead(d *schema.ResourceData, m interface{}) error {
res, err := api.Dcim.DcimModulesRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimModulesReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimModulesReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_module_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ func resourceNetboxModuleTypeRead(d *schema.ResourceData, m interface{}) error {
res, err := api.Dcim.DcimModuleTypesRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimModuleTypesReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimModuleTypesReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
11 changes: 6 additions & 5 deletions netbox/resource_netbox_power_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ func resourceNetboxPowerPanelRead(d *schema.ResourceData, m interface{}) error {
res, err := api.Dcim.DcimPowerPanelsRead(params, nil)

if err != nil {
errorcode := err.(*dcim.DcimPowerPanelsReadDefault).Code()
if errorcode == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
if errresp, ok := err.(*dcim.DcimPowerPanelsReadDefault); ok {
if errresp.Code() == 404 {
// If the ID is updated to blank, this tells Terraform the resource no longer exists (maybe it was destroyed out of band). Just like the destroy callback, the Read function should gracefully handle this case. https://www.terraform.io/docs/extend/writing-custom-providers.html
d.SetId("")
return nil
}
}
return err
}
Expand Down
Loading