API - Get Applications

jramm
New Contributor

Working on a script right now to export JAMF info to an ITAM solution.

So far I no issue pulling in any hardware info, since each has a unique name. I can't, however, figure out a way to grab the software.

Here's the meat of the script:

CI_type = 'Computer'

Correlation names from JAMF to manageengine

TAGS_CORRELATIONS = { 'serial_number': 'CI Name', 'name': 'Hostname', 'model_identifier': 'Model', 'building': 'JAMF Location',

'serial_number': 'Serial Number',

'model': 'Description', 'total_ram': 'Total Memory', 'username': 'Last Logged User', 'os_name': 'OS', 'os_version': 'OS Version', 'make': 'Manufacturer', 'mac_address': 'Primary MAC Address', 'alt_mac_address': 'Secondary MAC Address', '????': 'Software_Info',
}

Start of a script

JAMF_CREDENTIALS = base64.b64encode(bytes(JAMF_USENAME ':' JAMF_PASSWORD, 'utf-8')).decode('utf-8')

jamf_headers = { "authorization": "Basic " + JAMF_CREDENTIALS, "accept": "application/json"
}

errors = []

def xml_wrapper(func): def wrapper(args, kwargs): result = func(args, kwargs) reparsed = minidom.parseString(result) xml_string = reparsed.toxml(encoding='UTF-8').decode('UTF-8') print('XML sent to MEngine: ', reparsed.toprettyxml(indent=' ')) return xml_string return wrapper

def fetch_computer_by_id(session, computer_id): response = session.get( '{url}/JSSResource/computers/id/{id_n}'.format(url=JAMF_PRO_URL, id_n=str(computer_id)), headers={**jamf_headers, 'accept': 'application/xml'} ) return response.text

def set_parameter(record, name, value): parameter = ET.SubElement(record, 'parameter') p_name = ET.SubElement(parameter, 'name') p_value = ET.SubElement(parameter, 'value') p_name.text = name p_value.text = value

0 REPLIES 0