py-dep is a Python 3.6+ module designed to work with Apple's Device Enrollment Program (DEP) API. It is meant to be used as a means for Apple Resellers to be able to enroll their customers' eligible Apple devices into the customer institution's DEP account. Please consult the DEP API documentation (UAT, Production) for more details.
This is being open-sourced to gather feedback on how to make the module better and benefit the community at large.
Note: Before an authorized reseller may begin enrolling devices for their customers, Apple must take both the reseller and the customer through an onboarding process AND sign-off on the reseller's implementation of the DEP API. This is partially detailed in the DEP Design Requirements. Please contact your Apple representative for more information.
- Python 3.6 or later
- Contents of requirements.txt in your Python environment
- DEP client certs (UAT/PROD) signed by Apple
To achieve the "Sample REST(JSON) Request" for a Bulk Enroll Devices Request found here, we could use the following code:
import os
from datetime import datetime
from py-dep import dep
# Setup environment variables
os.environ['DEP_ENV'] = 'UAT'
os.environ['DEP_SHIPTO'] = '0000052010'
os.environ['DEP_RESELLER_ID'] = '16FCE4A0'
os.environ['DEP_UAT_CERT'] = '/path/to/acc/uat/cert.pem'
os.environ['DEP_UAT_PRIVATE_KEY'] = '/path/to/acc/uat/cert_private_key.pem'
# Create a list of Device objects
d1 = dep.Device("33645004YAM", "A123456").json()
d2 = dep.Device("33645006YAM", "A123456").json()
devices1 = [d1, d2]
# Create a list of Delivery objects and add Device objects' list
delivery1 = dep.Delivery('D1.2', datetime(2014, 10, 10, 5, 10, 00), devices1).json()
deliveries = [delivery1]
# Create an Order object and add Delivery objects list
order = dep.Order("ORDER_900123", datetime(2014, 8, 28, 10, 10, 10), "OR", "19827", "PO_12345", deliveries).json()
# Call the Bulk Enroll Devices endpoint with Order object
post_data, response_data, error_code, error_message, call_type = dep.bulk_enroll_devices("TXN_001122", order)
import os
from datetime import datetime
from py-dep import dep
# Setup environment variables
os.environ['DEP_ENV'] = 'PROD'
os.environ['DEP_SHIPTO'] = '0000052010'
os.environ['DEP_RESELLER_ID'] = '16FCE4A0'
os.environ['DEP_UAT_CERT'] = '/path/to/acc/uat/cert.pem'
os.environ['DEP_UAT_PRIVATE_KEY'] = '/path/to/acc/uat/cert_private_key.pem'
# Create a list of Device objects
d1 = dep.Device("33645004YAM", "A123456").json()
d2 = dep.Device("33645006YAM", "A123456").json()
devices1 = [d1, d2]
# Create a list of Delivery objects and add Device objects' list
delivery1 = dep.Delivery('D1.2', datetime(2014, 10, 10, 5, 10, 00), devices1).json()
deliveries = [delivery1]
# Create an Order object and add Delivery objects list
order = dep.Order("ORDER_900123", datetime(2014, 8, 28, 10, 10, 10), "OR", "19827", "PO_12345", deliveries).json()
# Call the Bulk Enroll Devices endpoint with Order object
post_data, response_data, error_code, error_message, call_type = dep.bulk_enroll_devices("TXN_001122", order)