Method: Jamf::NetworkSegment.my_network_segment

Defined in:
lib/jamf/api/classic/api_objects/network_segment.rb

.my_network_segment(refresh = false, name: false, api: nil, cnx: Jamf.cnx) ⇒ Integer, ...

Which network segment is seen as current? According to the Jamf Pro Admin Guide, the ‘smallest’ one - the one with fewest IP addrs within it. If multiple ones have the same number of IPs, then its the one with the lowest starting address

Parameters:

  • name (Boolean) (defaults to: false)

    return the name of the netsegment, not the id

Returns:

  • (Integer, String, nil)

    the id of the current net segment, or nil



342
343
344
345
346
347
348
349
350
351
352
# File 'lib/jamf/api/classic/api_objects/network_segment.rb', line 342

def self.my_network_segment(refresh = false, name: false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  my_ip = Jamf::Client.my_ip_address
  return nil unless my_ip

  id = network_segment_for_ip(my_ip, refresh: refresh, cnx: cnx)
  return id unless name

  map_all_ids_to(:name, cnx: cnx)[id]
end