A Jamf Classic communication framework written in Swift

Overview

JamfKit

JamfKit

Swift iOS macOS tvOS

Travis branch Codecov Codacy grade Carthage compatible CocoaPods

JamfKit is an iOS / macOS / tvOS framework to communicate with the JSS API offered by any Jamf host.

Summary

Features

  • Includes JSON encoding / decoding support for most of the JSS objects
  • Includes Objective-C support
  • Includes Swift 5+ support
  • Includes ready-for-consumption CRUD URLRequest for JSS endpoints
  • Includes demonstration playgrounds for class handling or request generation

Installation

Carthage

To integrate JamfKit into your project, add the following line in your Cartfile:

github "Ethenyl/JamfKit"

Then run the following command:

$ carthage update

Cocoapods

To integrate JamfKit into your project, add the following line in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'JAMFKit'
end

Then run the following command:

$ pod install

Architecture

Protocols

Protocol Description
Endpoint Represents any JSS object that is matched by a JSS endpoint.
Identifiable Represents any JSS object that can be identified (either by ID or by name).
Requestable Represents an object that can be used to perform requests with any JSS endpoint.
Subset Represents any JSS object that contains a general object that can identify it.

Requestable conformance

The class that conform to Requestable exposes the following elements:

  • An failable initializer that takes a JSON payload and return the instantiated object
  • A function to return the JSON payload that represents the instance of the object

Classes

Class Desscription
BaseObject Represents the common denominator between most of the JSS objects which must contains at least an identifier and a name properties.
Building Represents a physical building.
Computer Represents a computer managed by Jamf, contains the general / location / purchasing information about the hardware.
ComputerCommand Represents a logical command that can be executed on any hardware element manageg by Jamf.
ComputerConfigurationProfile Represents a logical configuration profile that can be applied to any computer managed by Jamf.
ComputerGroup Represents a group of computers managed by Jamf, contains grouping information.
Department Represents a physical department.
DirectoryBinding Represents a logical binding between a computer and an active directory user.
MobileDeviceConfigurationProfile Represents a logical configuration profile that can be applied to any mobile device managed by Jamf.
MobileDevice Represents a mobile device managed by Jamf, contains the general information about the device.
MobileDeviceGroup Represents a group of mobile devices managed by Jamf, contains grouping information.
NetbootServer Represents a physical netboot server, contains information about the server and it's configuration.
NetworkSegment Represents a physical network segment, contains information about the segment and it's configuration.
Package Represents a logical application package, contains information about the application requirements and capabilities.
Partition Represents a logical partition for an hard drive installed inside an hardware element managed by Jamf.
Policy Reprents as logical policy that can be applied to any hardware element managed by Jamf.
PreciseDate Represents a logical date within JSS api, contains 3 properties, the date itself, an epoch variant of the date and an UTC version of the date.
Printer Represents a physical printer, contains information about the printer and it's configuration.
Script Represents a logical script that can be executed on one (or more) machine managed by Jamf.
Site Represents a physical location (building, office, etc.).
SMTPServer Represents the physical SMTP server configuration.
User Represents a Jamf user and contains the identification properties that are required to contact the actual user and identify the hardware devices assigned to him / her.

Usage

Getting started

Playgrounds

To get a quick look on how you can use JamfKit in your Jamf related features, you can check the Playgrounds included within the workspace.

Also check the unit tests, they should cover most of your needs.

Models

Most of the classes can be initialized with the bare minimul values, all the properties are then available for modification.

Requests

By adhering to the different CRUD protocols (Creatable, Readable, Updatable & Deletable), most of the JSS objects listed above are capable of supplying varying URLRequest that should fit any needs.

You'll find below the basic functions to get URLRequest:

Function Type HTTP Method Example Output
createRequest() instance POST building.createRequest() http://jss.host/jss/objects/1
readAllRequest() static GET Building.readAllRequest() http://jamf.com/jss/objects
readRequest(identifier:) static GET Building.readRequest(identifier: "12345") http://jamf.com/jss/objects/1
readRequest() instance GET building.readRequest() http://jamf.com/jss/objects/1
updateRequest() instance PUT building.updateRequest() http://jamf.com/jss/objects/1
deleteRequest(identifier:) static DELETE Building.deleteRequest(identifier: "12345") http://jamf.com/jss/objects/1
deleteRequest() instance DELETE building.deleteRequest() http://jamf.com/jss/objects/1

Some objects will offer variants of those requests, like MobileDevice with readRequestWithName() or deleteRequestWithSerialNumber() (with both static and instance variants).

Contributing

So, you want to help improve JamfKit? That's great! Any useful contribution is welcome!

Check CONTRIBUTING for more details on how you can contribute to JamfKit.

Code of conduct

Any contributions (issues, pull requests, comments, etc.) to JamfKit are more than welcome.

But before making any contribution, please make sure that you follow the CODE OF CONDUCT.

Otherwise, there's a great chance that your contribution will be removed / blocked / hidden.

FAQ

None for the moment.

Credits

JamfKit is owned and maintained by Ethenyl.

You can join the list by contributing to the repository.

License

JamfKit is released under the MIT license. See LICENSE for more details.

Comments
  • tvOS Compatibility

    tvOS Compatibility

    Missing functionnality

    Hi 👋 ,

    Looking to please request tvos compatibility to pull in data from our Jamf instance to Apple TV Dashboard.

    Platform syntax in podfile: platform :tvos, '10.0'

    pod install returns:

    [!] The platform of the target `Dashboard` (tvOS 10.0) is not compatible with `JAMFKit (0.3.0)`, which does not support `tvos`

    Thank you! :)

    Miscellaneous

    Information | Value | ------------------------------|------------------------------| Language | Swift Platform | tvOS Platform version | 10.0 JamfKit version | latest as of March 3rd 2018 Package manager | CocoaPods Package manager version | 1.3.1 XCode version | 9.2

    Feature 
    opened by jeffreyjbrown 2
  • Allow users to perform request(s) against the configured Jamf host

    Allow users to perform request(s) against the configured Jamf host

    New feature

    Short description

    Users of JamfKit can make the request toward the Jamf host on their own accord and simply pass the extracted JSON with the objects supplied by JamfKit to obtain instances of these.

    But, to ease the development process, JamfKit can also supply the output of the request needed for each single object.

    Missing functionnality

    Users should be able to configure the current Jamf host parameters which are going to be used to preconfigure the URLRequest used by JamfKit.

    Once the host configuration is fully completed (host, port, username, password) a singleton will allow users to retrieve the following for each type of object:

    • the fully configured (verb, url, headers, parameters, body) URLRequest for performing a request with the framework of their choice (they'll take care of parsing the result)
    • the output of the same request, everything related to JSON deserialization is taken care of, the result could be a single object, some objects or simply an error

    Implementation

    First off, JamfKit needs to supply a way of configuring the host, this can be done through a Singleton.

    Once configuration is done, the same manager can supply different types of request based on each JSS objects (some endpoints are read-only, others are CRUD ready) for the users to consume with the framework of their choice (AFNetworking, Moya, Alamofire, NSURLSession, etc.).

    The library could also perform NSURLSession requests for the user and simply return the instances of the objects that are expected from the request or an error if something went wrong.

    Feature 
    opened by Ethenyl 2
  • Improve Building model

    Improve Building model

    Short description

    The Building model is out of sync with the Jamf Pro API object.

    Missing functionnality

    Some fields are missing and must be implemented in order to comply with the API.

    Feature 
    opened by Ethenyl 1
  • Implement ConfigurationProfiles (MobileDevice / OSX)

    Implement ConfigurationProfiles (MobileDevice / OSX)

    Missing functionality

    The two following configuration profiles are missing from the models:

    • MobileDeviceConfigurationProfile
    • OSXConfigurationProfile

    Miscellaneous

    Mobile device

    {
        "general": {
            "id": 0,
            "name": "Corporate Wireless",
            "description": "string",
            "site": {
                "id": 0,
                "name": "None"
            },
            "category": {
                "id": 0,
                "name": "string",
                "priority": 0
            },
            "uuid": "55900BDC-347C-58B1-D249-F32244B11D30",
            "deployment_method": "Install Automatically",
            "redeploy_on_update": "Newly Assigned",
            "redeploy_Dayss_before_certificate_expires": 0,
            "payloads": "string"
        }
    }
    

    OSX

    {
        "general": {
            "id": 12345,
            "name": "Corporate Wireless",
            "description": "string",
            "site": {
                "id": 0,
                "name": "None"
            },
            "category": {
                "id": 0,
                "name": "string",
                "priority": 0
            },
            "distribution_method": "Install Automatically",
            "user_removable": true,
            "level": "computer",
            "uuid": "88F8C1DB-D92A-4D10-95FB-CE7EDE82B93E",
            "redeploy_on_update": "Newly Assigned",
            "payloads": "string"
        }
    }
    
    Feature 
    opened by Ethenyl 1
  • Add basic support for generating requests

    Add basic support for generating requests

    Summary

    Implement the functions that will return URLRequests for all requestable objects.

    Implements #70 and #71.

    Miscellaneous

    Supports Objective-C meaning that each single object will implement the public version of each function but under the hood, the generic functions will be used. 😭

    Supports CREATE, READ, UPDATE & DELETE methods.

    Feature 
    opened by Ethenyl 1
  • Rework models to follow Protocol Oriented Programming paradigm

    Rework models to follow Protocol Oriented Programming paradigm

    Short description

    To improve maintainability & cleanliness, the models needs to be reworked in a Protocol Oriented Programming way.

    Implementation

    Most of the classes inherits from BaseObject class or Identifiable protocol which is kind of messy. All the classes should adopt protocols instead of inheriting other classes.

    Task 
    opened by Ethenyl 1
  • Provide URLRequest for JSS endpoints

    Provide URLRequest for JSS endpoints

    New feature

    Short description

    Once the SessionManager is fully configured, it should be possible to retrieve URLRequests for all the models supported by JamfKit.

    Missing functionnality

    The SessionManager should be able to produce URLRequest that can be used by any user against the network communication framework of their choice.

    Those requests should be available for the 4 methods currently supported by JSS:

    • PUT
    • GET
    • POST
    • DELETE

    Implementation

    TBD

    Feature 
    opened by Ethenyl 1
  • Add Jamf host configuration

    Add Jamf host configuration

    Summary

    Implements #64 by adding the basic element needed for configuring the URLRequest that will be returned / used later on by the framework.

    Miscellaneous

    Added SessionManager. Added base request creation. Added base errors.

    Feature 
    opened by Ethenyl 1
  • Allow users to configure the Jamf host to perform request(s) against

    Allow users to configure the Jamf host to perform request(s) against

    New feature

    Short description

    Required by #63.

    Implementation

    Supply the users with a simple mean of configuring the Jamf host to target for JamfKit.

    This will be used later to output URLRequest or to perform them directly.

    Feature 
    opened by Ethenyl 1
  • Add Objective-C interoperability

    Add Objective-C interoperability

    Implements #33.

    Splitted ComputerCommandGeneral from ComputerCommand. Added @objc on public properties. Refactored description properties to rely on class type instead of manual type.

    Feature 
    opened by Ethenyl 1
  • Rework PreciseDate JSON serialisation

    Rework PreciseDate JSON serialisation

    Context

    The PreciseDate class has been constructed to mimic the same behaviour as JSS payload when it comes to dates.

    By acception a base key name, it allows the reconstruction of the 3 original keys for any date, like that:

    {
        "example_date": "XXX",
        "example_date_epoch": 0,
        "example_date_utc": "XXX+0500"
    }
    

    If those keys were embedded in a single key it would have been much more simple to reconstruct the json before sending it to JSS.

    An updated payload:

    {
        "example_date": {
            "date": "XXX",
            "epoch": 0,
            "utc": "XXX+0500"
        }
    }
    

    Which in turn would improve the injection of each date in any JSON payload.

    How it's currently done:

    if let exampleDate = exampleDate {
        json.merge(exampleDate.toJSON()) { (_, new) in new }
    }
    

    Currently, this solution is problematic since the test coverage can't make it inside the block.

    Issue

    Find a better way of generating / injecting any date's JSON into another JSON payload.

    Feature 
    opened by Ethenyl 0
  • Implement Swift 4's Codable protocol for JSON handling

    Implement Swift 4's Codable protocol for JSON handling

    Already gave it a try, pretty frustrating since there's a lot of unconventional JSS objects that are complex to translate into Codable objects.

    Still worth a try, maybe some hybrid solution could be nice but it might be confusing to some.

    Feature 
    opened by Ethenyl 0
Releases(0.3.3)
  • 0.3.3(Jun 10, 2019)

  • 0.3.2(Oct 29, 2018)

  • 0.3.1(Apr 29, 2018)

  • 0.3.0(Mar 13, 2018)

    What's new

    Added

    • Added the possibility of configuring the Jamf host to target for generated URLRequest [#64]
    • Added the possibility to generate URLRequest [#70]
    • Implemented Computer configuration profile and Mobile device configuration profile models [#73]

    Modified

    • Reworked objects with protocol composition [#71]
    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Mar 13, 2018)

    What's new

    Added

    • Implemented Building model [#2]
    • Implemented Computer model [#3]
    • Implemented Department model [#4]
    • Implemented Mobile device model [#5]
    • Implemented Policy model [#6]
    • Implemented Printer model [#7]
    • Implemented Mobile device group model [#24]
    • Implemented Netboot server model [#25]
    • Implemented Network segment model [#26]
    • Implemented Package model [#27]
    • Implemented SMTP server model [#28]
    • Implemented computer command model [#29]
    • Implemented Computer configuration model [#30]
    • Implemented Computer group model [#31]
    • Implemented Objective-C compatibility [#33]
    • Implemented Directory binding model [#45]
    • Implemented Script model [#46]
    • Implemented Partition model [#47]

    Modified

    • Renamed solution to JamfKit (was JAMFKit previously) [#37]
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Mar 13, 2018)

    What's new

    Added

    • Implemented Account model [#1]
    • Implemented Site model [#8]
    • Implemented User model [#9]
    • Implemented Base object [#10]
    • Implemented Hardware model [#19]
    • Added CocoaPods compatibility [#16]
    Source code(tar.gz)
    Source code(zip)
Owner
Damien R.
Senior Software Engineer @Ogury.
Damien R.
Poetic is a classic poetry reader. Recently released on the App Store.

Poetic is a classic poetry reader. Enjoy thousands of poems from the greatest English poets.

Dean Thompson 4 Nov 25, 2022
Seaglass is a truly native macOS client for Matrix. It is written in Swift and uses the Cocoa user interface framework.

Seaglass is a truly native macOS client for Matrix. It is written in Swift and uses the Cocoa user interface framework.

null 1 Jan 17, 2022
Nudge is application for enforcing macOS updates, written in Swift

Nudge (macadmin's Slack #nudge) Nudge is application for enforcing macOS updates, written in Swift 5.5 and SwiftUI 5.2. In order to use the newest fea

null 624 Dec 29, 2022
A grocery list app for families written in Swift using Firebase Realtime Database

FamiList | Grocery list app in Swift FamiList is a grocery list app for families written in Swift using Firebase Realtime Database. You can add differ

Wasan Ibrahim 2 Jul 31, 2022
Simple Wolfenstein 3D clone written in Swift

Mein Leben! Swiftenstein is a partial reimplementation of ID Software's 1992 classic FPS Wolfenstein 3D in Swift for iOS. It is not a complete game, j

Nick Lockwood 350 Oct 22, 2022
Simple iOS app written with SwiftUI (and, of course, Swift) to begin exploring it.

WishList Tracking: An exploration with SwiftUI Simple iOS app written with SwiftUI (and, of course, Swift) to begin exploring it. Goal: Get used to Vi

null 0 Dec 26, 2021
Todo-list - Simple todo list app written in Swift

About TodoApp TodoApp is sinmple todo list app that I created in my free time, i

null 2 Aug 30, 2022
NES - NES emulator, written in Swift

Swift NES NES emulator, written in Swift. NESKit: Emulator core. License GPL v3.

Swift Simpers 0 Jan 10, 2022
A open source Swift app for iOS 13 that allows you to check your NFC transit card information. Written with SwiftUI.

ABANDONED Metrodroid, which TransitPal was heavily inspired by, now has its own fully functional iOS app! It should be in the App Store "soon". I stro

Robbie Trencheny 132 Jun 30, 2022
An iOS App to generate phonetic keys for your Chinese contacts. Written in Swift.

An iOS App to add phonetic keys with Pinyin for Chinese(SC & TC) names. Your Contacts will be sorted by alphabet automatically even under English System.

iAugus 595 Dec 27, 2022
iOS Open Source Application written in Swift. App to manage borrowed books at UFRGS using SABI.

RenovaLivrosUFRGS iOS Open Source Application written in Swift. App to manage borrowed books at UFRGS using SABI. App in portuguese, code and comments

Matheus Cavalca 5 Feb 10, 2022
Jotify is an iOS app used for lightning fast note-taking and reminders, all written in swift.

Jotify About Jotify is an iOS app used for lightning fast note-taking and reminders, all written in swift. It uses several of Apple's newest framework

Harrison Leath 122 Jan 5, 2023
Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController.

Todo Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController

Jake Lin 273 Dec 29, 2022
An iOS application written in Swift to demonstrate how to implement a Clean Architecture in iOS

Reminders iOS An iOS application written in Swift to demonstrate how to implement a Clean Architecture in iOS. Idea The idea is to implement the simpl

Tiago Martinho 306 Nov 9, 2022
Simple RSS reader app written in Swift

Feeds4U Simple RSS reader app written in Swift. Contributions All PRs should be directed to 'develop' branch. Important Note Use code as you wish. Don

Evgeny Karkan 62 Nov 23, 2022
iOS client for Giphy written in Swift with ReactiveCocoa

Giraffe iOS client for Giphy written in Swift with ReactiveCocoa Requirements iOS 10.0 Beta Xcode 8 Beta 2 Swift 2.3 Carthage Why S

Yevhen Dubinin 43 Feb 10, 2022
An open source walk tracking iOS App written in Swift

Swift-Walk-Tracker An open source walk tracking iOS App written in Swift About The walk tracking application was intended to be incredibly simplistic.

Kevin VanderLugt 129 Nov 15, 2022
ToDoList - A To Do app, written in Swift for iOS.

A simple Todo list A To Do app, written in Swift for iOS. Project is build on MV

null 0 Feb 16, 2022
Finance App written in Swift and SwiftUI

Finance App written in Swift and SwiftUI. Modular MVVM architecture (SPM) with Composition Root.

Alexander Tereshkov 7 Nov 18, 2022