Method: Jamf::NetworkSegment.my_network_segments

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

.my_network_segments(refresh = false, names: false, api: nil, cnx: Jamf.cnx) ⇒ Array<Integer>, Array<String>

Find the current network segment ids for the machine running this code

See my_network_segment to get the current one according to the server.

Parameters:

  • names (Boolean) (defaults to: false)

    the array will contain Network Segment names, not ids

Returns:

  • (Array<Integer>, Array<String>)

    the NetworkSegment ids or names for this machine right now.



324
325
326
327
328
329
330
331
332
# File 'lib/jamf/api/classic/api_objects/network_segment.rb', line 324

def self.my_network_segments(refresh = false, names: false, api: nil, cnx: Jamf.cnx)
  cnx = api if api

  ids = network_segments_for_ip Jamf::Client.my_ip_address, refresh, cnx: cnx
  return ids unless names

  ids_to_names = map_all_ids_to :name, cnx: cnx
  ids.map { |id| ids_to_names[id] }
end