Slide 1

Slide 1 text

© JAMF Software, LLC API 101: The Building Blocks of Automation 9:00–9:45 am UP NEXT

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

© JAMF Software, LLC Christopher Ball Implementation Engineer Jamf Jonathan Yuresko Implementation Engineer Jamf

Slide 4

Slide 4 text

© JAMF Software, LLC API 101: The Building Blocks of Automation Presentation agenda: What is an API? But how do I use it? Does Jamf have APIs? That’s cool…so? You mean I can automate all the things?

Slide 5

Slide 5 text

© JAMF Software, LLC What is an API? (Boring explanation) “Application programming (or program) interface: a set of protocols used by programmers to create applications for a specific operating system or to interface between the different modules of an application.” ~Dictionary.com

Slide 6

Slide 6 text

© JAMF Software, LLC What is an API? Why point and click, when you can automate? A point-and-click GUI (graphical user interface) relies on real-time human-interaction every time you want to do something. An API allows you to tell a computer to accomplish the same thing in an automated fashion.

Slide 7

Slide 7 text

© JAMF Software, LLC What is an API? (Building blocks) Terminology Authentication - Credentials needed to securely execute a task Endpoint - Where on the application the data/record is held Call/Request - Initiate communication with the application Response - Data/confirmation of request/action

Slide 8

Slide 8 text

© JAMF Software, LLC What is an API? (Building blocks) Actions/Verbs GET - Retrieve desired information POST - Create a brand new record PUT - Update an existing set of info or record DELETE - Permanently remove info or record

Slide 9

Slide 9 text

© JAMF Software, LLC But how do I use it? Endpoint Authentication Request Server URL Action/ Verb

Slide 10

Slide 10 text

© JAMF Software, LLC But how do I use it? (Request) cURL/curl - Tells the computer to perform the request Flags “-skH”: s - Silent/suppress output k - Proceed without verifying server certs H - Headers, dictates style/type of text to communicate with server (json vs xml)

Slide 11

Slide 11 text

© JAMF Software, LLC Authentication is required to perform tasks via API Flag “-u” tells the curl the next string/data is specifying the credentials needed to perform task Basic authentication or token-based auth But how do I use it? (Auth)

Slide 12

Slide 12 text

© JAMF Software, LLC Target server URL needed to point request to Endpoint (i.e. JSSResource/computers) - Must specify a folder/segment/category of data in order to execute a task or gather data Account used in authentication must have permission to perform tasks within endpoint But how do I use it? (Endpoint)

Slide 13

Slide 13 text

© JAMF Software, LLC Flag “-X" Tells curl task/verb/action to perform GET/POST/PUT/DELETE are the available options If a verb is not specified, it will default to GET But how do I use it? (Action/Verb)

Slide 14

Slide 14 text

© JAMF Software, LLC 780 px 650 px Max image dimensions Does Jamf have an API? Classic API Current API Most endpoints Basic authentication GET JSON/XML Send XML only

Slide 15

Slide 15 text

© JAMF Software, LLC 780 px 650 px Max image dimensions Does Jamf have an API? Jamf Pro API (UAPI) Token-based auth Will eventually mirror Classic API Allows sending of JSON

Slide 16

Slide 16 text

© JAMF Software, LLC Does Jamf have an API?

Slide 17

Slide 17 text

© JAMF Software, LLC Parsing XML in Bash XML - use ‘xmllint --xpath' to isolate specific data. Add ‘text()’ to the end of the path to strip XML elements That’s cool…so? Command Location of data in XML

Slide 18

Slide 18 text

© JAMF Software, LLC That’s cool…so?

Slide 19

Slide 19 text

© JAMF Software, LLC Parsing XML in Bash That’s cool…so? Result: admin’s Mac mini

Slide 20

Slide 20 text

© JAMF Software, LLC That’s cool…so?

Slide 21

Slide 21 text

© JAMF Software, LLC Parsing XML in Bash That’s cool…so? Result: C07HH52NDJD2

Slide 22

Slide 22 text

© JAMF Software, LLC That’s cool…so? Parsing JSON in Python Module ‘json’ is required to parse json data Module ‘requests’ is one of many ways to interact with an API

Slide 23

Slide 23 text

© JAMF Software, LLC That’s cool…so? Goal: Rename computer to serial number 1. Get computer’s current name 2. Determine computer’s serial number 3. If needed, adjust computer’s name to serial number

Slide 24

Slide 24 text

© JAMF Software, LLC Step 1: Get computer’s current name by ID Parsing: Get value(s) from response body from an API call xmllint: Tool used to extract XML from response Parsed result: Admin’s Mac Mini That’s cool…so?

Slide 25

Slide 25 text

© JAMF Software, LLC Step 2: Get computer’s serial number Parsed result: C07HH52NDJD2 “Admin’s Mac mini” is not “C07HH52NDJD2” Device name adjustment required That’s cool…so?

Slide 26

Slide 26 text

© JAMF Software, LLC Step 3: Adjust computer name Flag “-d” sends data with PUT/POST request Specify type of data sending “content-type” Jamf Pro accepts XML for PUT/POST/DELETE Device name adjusted to: “C07HH52NDJD2” That’s cool…so?

Slide 27

Slide 27 text

© JAMF Software, LLC You mean I can automate all the things? Automated task examples • Push/Remove restrictions based on time • Automate the generation of complex reports • Enforce branding/naming • Automate onboarding by creating 3rd party SaaS accounts • Automate management commands • Remediate security/compliance issues

Slide 28

Slide 28 text

© JAMF Software, LLC You mean I can automate all the things?

Slide 29

Slide 29 text

© JAMF Software, LLC Tools that use Jamf’s APIs • https://github.com/jamf/JamfMigrator - Move records from a Jamf Pro instance to another Jamf Pro instance (i.e. Test to Prod) • https://github.com/mike-levenick/mut - Automate the population of records in your Jamf Pro • https://github.com/jamf/JAWA - Utilize this webhook server to automate your processes based on triggers/actions • https://github.com/kc9wwh/JamfProGroupsScoped - Find out what policies, profiles and apps are scoped to specific groups in your Jamf Pro • https://github.com/rustymyers/jamfMDMTools - Send automated MDM commands to devices

Slide 30

Slide 30 text

© JAMF Software, LLC Resources - jamf.it/jnucapi101 developer.jamf.com marketplace.jamf.com

Slide 31

Slide 31 text

© JAMF Software, LLC Questions?

Slide 32

Slide 32 text

THANK YOU!

Slide 33

Slide 33 text

© JAMF Software, LLC Thank you for listening! Give us feedback by completing the 2-question session survey in the JNUC 2019 app. UP NEXT Common Pitfalls of Jamf Administration and How to Fix Them 10:15-11:00 am