Events API Mobile Device Enrolled/Unerolled

bentoms
Release Candidate Programs Tester

Hi All,

Has anyone written a plugin for the JSS Events API that will perform an action when a mobile device is enrolled or unerolled (on JSSv9)?

Also, is there some v9 Events API documentation?

5 REPLIES 5

GaToRAiD
Contributor II

I might be wrong on this, but isn't the API rested, not event driven? Thus the API can't be reactive, it can only be used to add/remove/read information from JSS.

bentoms
Release Candidate Programs Tester

@GaToRAiD.. It was there in v8.. Hoping it still is in v9.

https://jamfnation.jamfsoftware.com/discussion.html?id=5640

GaToRAiD
Contributor II

@bentoms you are correct. I completely forgot about these.

drhoten
Contributor II
Contributor II

Hi Ben -

Yes, the events API is still available in v9 and here are some resources and tips that should help you out.

First, if you have not already found it there is a recording from last year's JNUC that is a good introduction to the API and goes into some detail about tying into the Events API: http://www.jamfsoftware.com/resources/the-new-and-improved-casper-suite-9-api/

The other thread you found has some code examples, but I noticed the documentation was out of date.

I'll email you the latest version of the documentation to you, while we work on finding a permanent home for it on our website. For others reading this thread afterwards, please reach out to your technical account manager if it is still not up on our site. (Most likely it will be located at http://www.jamfsoftware.com/developer-resources/.)

For your plug-in, you'll want to look at the following two events
- MobileDeviceEnrolled
- MobileDeviceUnEnrolled

For a mobile device enrollment, you'll also want to make sure to also check the event is completed. Otherwise if you'll receive 6+ events due to how the mobile device enrollment process works.

So based on sample code in the other thread, you could do something similar to this. (Note: this code may not compile, I was just going off of memory.)

// Pseudo code
public JAMFEventNotificationMonitorResponse eventOccurred(JAMFEventNotificationParameter param) {
   EventType event = param.getEventType();
   EventTypeIdentifier eventType = event.getIdentifier();
   switch (eventType) {
      case ComputerInventoryCompleted:
      case MobileDeviceCommandCompleted:
         MobileDeviceCommandCompleted mdcc = (MobileDeviceCommandCompleted) event;
         if mdcc.getCommand().equals("UpdateInventory") && mdcc.getResultStatus().equals("Acknowledged")
         {
            // Enrollment complete
         }
      default:
   }
}

Starting in v9.2 we also added a new event which allows you to listen for API operations. So that means you can listen for any standard HTTP verbs such as POST, PUT, GET or DELETE in your plug-ins.

I hope that helps you out, and reach out if you have any questions.

Doug

drhoten
Contributor II
Contributor II

For folks finding this thread after the initial conversation, you can now find the events API documentation at http://www.jamfsoftware.com/developer-resources/.

Doug