Skip to content

Commit

Permalink
feat: Update ipam_ip_addresses
Browse files Browse the repository at this point in the history
Fixes: #196
  • Loading branch information
amhn authored and smutel committed Mar 14, 2023
1 parent 89f477c commit df80a60
Show file tree
Hide file tree
Showing 6 changed files with 427 additions and 198 deletions.
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_ip_addresses/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# IP addresses can be imported by id
terraform import netbox_ipam_ip_addresses.ip_test 1
48 changes: 48 additions & 0 deletions netbox/internal/util/nested.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,38 @@ func GetCustomFieldUIVisibilityValue(nested *models.CustomFieldUIVisibility) *st
return nested.Value
}

func GetIPAddressAssignedObject(nested *models.IPAddress) (*string, *int64) {
if nested == nil {
return nil, nil
}

return nested.AssignedObjectType, nested.AssignedObjectID
}

func GetIPAddressFamilyLabel(nested *models.IPAddressFamily) *string {
if nested == nil {
return nil
}

return nested.Label
}

func GetIPAddressRoleValue(nested *models.IPAddressRole) *string {
if nested == nil {
return nil
}

return nested.Value
}

func GetIPAddressStatusValue(nested *models.IPAddressStatus) *string {
if nested == nil {
return nil
}

return nested.Value
}

func GetNestedIPAddressAddress(nested *models.NestedIPAddress) *string {
if nested == nil {
return nil
Expand All @@ -28,6 +60,14 @@ func GetNestedIPAddressAddress(nested *models.NestedIPAddress) *string {
return nested.Address
}

func GetNestedIPAddressID(nested *models.NestedIPAddress) *int64 {
if nested == nil {
return nil
}

return &nested.ID
}

func GetNestedClusterGroupID(nested *models.NestedClusterGroup) *int64 {
if nested == nil {
return nil
Expand Down Expand Up @@ -107,3 +147,11 @@ func GetNestedVlanID(nested *models.NestedVLAN) *int64 {

return &nested.ID
}

func GetNestedVrfID(nested *models.NestedVRF) *int64 {
if nested == nil {
return nil
}

return &nested.ID
}
12 changes: 12 additions & 0 deletions netbox/internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ func ConvertNestedASNsToASNs(asns []*models.NestedASN) []int64 {
return tfASNs
}

func ConvertNestedIPsToIPs(asns []*models.NestedIPAddress) []int64 {
var tfASNs []int64

for _, t := range asns {
asn := t.ID

tfASNs = append(tfASNs, asn)
}

return tfASNs
}

func ConvertNestedVlansToVlans(vlans []*models.NestedVLAN) []int64 {
var tfVlans []int64

Expand Down
Loading

0 comments on commit df80a60

Please sign in to comment.