convert the JSON data from the Jamf Pro API into Swift objects.fetch a list of computers using the token.use the username and password to get a Jamf Pro API authentication token from the API.To achieve this, our tool will have to perform a few essential steps: The goal of our command line tool is simple: we want to list all the computers enrolled in the Jamf Pro server, together with their attributes, like the Device ID and the enrollment date. Lastly, we will be exclusively using the Jamf Pro API, but the principles can also be used with the classic API for those that prefer that version instead. Jamf's Developer pages provide a wealth of documentation with plenty of sample code examples. Note: This tutorial will also not go into much depth about the Jamf Pro API and how it works. Any account will do, but for security purposes, an API test account that is restricted to only read and update Computer and Category records is suggested. You also need a Jamf Pro account for API access. Jamf Cloud customers may request a free sandbox instance through their Customer Success team for testing and development. In line with best practices, it is recommended you use a test environment and not your production server while learning. To use the Jamf Pro API, you need access to a Jamf Pro instance. You can download Xcode from the Mac App Store or optionally from the downloads portal if you have an Apple Developer account. You need Xcode 13 or higher to build against macOS Monterey. This goes together with the macOS Monterey requirement. While dropping support for Big Sur and older versions of macOS may not be possible for some MacAdmins, the features included with the newest version of macOS does simplify the code significantly. It will also use some SwiftUI features also introduced in macOS Monterey. This tutorial will use some features that were introduced in Swift 5.5, which is included with macOS Monterey. Since it is beyond the scope of this series to explain Swift, I recommend great tutorials from Apple and third parties to help those who have little to no idea of programming or scripting in general macOS Monterey (or newer) You will need a basic understanding of programming concepts and Swift to follow this tutorial. What you will need Basic understanding of Swift Also, the object-oriented nature of Swift allows us to reuse large swaths of code, which we will utilize for the command line tool when we build the SwiftUI application in a later tutorial. We will also create code to get the API password out of the macOS Keychain. Goal: Build a command line tool that reads data from the Jamf Pro API.Ī command line tool does not require much of a user interface, which means we can focus on the process of getting the data out of Jamf. In this series of posts, I will show how you can build simple Swift tools and apps to interact with the Jamf Pro API. This combination makes Swift and SwiftUI a strong choice for tools and applications that interact with APIs, such as the Jamf Pro API.Īside from SwiftUI, there have also been changes in recent updates to Swift, which make features like these more accessible to programmers and admins just getting started with the language. Another strength of Swift and its frameworks is fetching and parsing data from web APIs. While some MacAdmins may consider Swift to be one of the more “complex” programming languages, it nevertheless has some definite strengths over languages considered “less complex”, such as shell scripting.įor starters, with SwiftUI, creating user interfaces is comparatively simple. In 2018, Apple also introduced SwiftUI, a Swift-native framework to build user interfaces.Īs administrators, we need tools that provide access to system information and functionality but are also easy to create, manage and deploy. Apple introduced Swift in 2014 with the goal of creating a new, modern programming language that was suitable for all Apple platforms - from watchOS to macOS - including additional platforms yet to come.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |