Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement skip_expression_validation, update sort and filter values for Jamf Pro 11.3 #58

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nstrauss
Copy link
Contributor

Follow on work from #57 There may be future work planned to more efficiently or dynamically validate support fields, but for now the API continues to outpace SDK releases.

My suggestion here is to support optionally skipping validation altogether for applicable endpoints. I've added an implementation for a new param skip_expression_validation, a boolean which is False by default. I'm not familiar with the extended typing system used so please correct me wherever the pattern is wrong. Though I think validation is a good goal, the API's response is already clear when an unsupported field is used. With additional validation occurring in the SDK, the result in many cases is not being able to use the endpoint at all.

{
    "httpStatus": 400,
    "errors": [
        {
            "code": null,
            "description": "Cannot filter by field [deviceOwnershipType]. Fields that can be used in filtering results of this endpoint: [meid, osBuild, modelIdentifier, osRapidSecurityResponse, userPhoneNumber, tethered, currentMobileCountryCode, purchasePrice, deviceLocatorServiceEnabled, deviceId, purchasingContact, building, imei2, passcodePresent, iccid, emailAddress, model, bluetoothLowEnergyCapable, passcodeCompliant, serialNumber, purchasingAccount, ipAddress, timeZone, exchangeDeviceId, lifeExpectancyYears, lastInventoryUpdateDate, sharedIpad, devicePhoneNumber, dataRoamingEnabled, declarativeDeviceManagementEnabled, residentUsers, currentMobileNetworkCode, carrierSettingsVersion, position, poNumber, diagnosticAndUsageReportingEnabled, eid, fileEncryptionCapable, personalHotspotEnabled, itunesStoreAccountActive, displayName, usedSpacePercentage, lostModeEnabled, assetTag, wifiMacAddress, locationServicesForSelfServiceMobileEnabled, homeMobileNetworkCode, purchasedOrLeased, mobileDeviceId, osVersion, blockEncryptionCapable, vendor, managed, availableSpaceMb, passcodeCompliantWithProfile, osSupplementalBuildVersion, passcodeLockGracePeriodEnforcedSeconds, bluetoothMacAddress, currentCarrierNetwork, airPlayPassword, department, udid, personalDeviceProfileCurrent, batteryLevel, cloudBackupEnabled, roaming, languages, activationLockEnabled, appleCareId, fullName, modemFirmwareVersion, capacityMb, homeCarrierNetwork, room, appAnalyticsEnabled, dataProtection, homeMobileCountryCode, supervised, locales, imei, modelNumber, quotaSize, doNotDisturbEnabled, username]",
            "id": "0",
            "field": null
        }
    ]
}

Example usage:

client.pro_api.get_mobile_device_inventory_v2(
    sections=["GENERAL", "USER_AND_LOCATION", "HARDWARE"],
    filter_expression=filter,
    skip_expression_validation=True,
)

I've also updated the existing fields in api_options.py. Where I made changes I chose to sort by alpha, though that's not approximate to the API docs. Don't think it was "wrong" and made diffing easier.

Let me know thoughts or if this is a change you'd consider. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant