-
Notifications
You must be signed in to change notification settings - Fork 0
API Custom Profiles
- Methods
- Payload model
- List profiles
- Get a profile
- Create a profile
- Update a profile
- Delete a profile
- See also
The resource wraps the /api/v1/library/custom-profiles endpoint and exposes five methods:
| Method | Description | Returns |
|---|---|---|
list() |
All custom profiles | PayloadList[CustomProfilePayload] |
get(id) |
A single profile by ID | CustomProfilePayload |
create(...) |
Create a profile from a .mobileconfig
|
CustomProfilePayload |
update(id, ...) |
Update an existing profile | CustomProfilePayload |
delete(id) |
Delete a profile | None |
Methods return a CustomProfilePayload with these key attributes:
| Attribute | Type | Description |
|---|---|---|
id |
str |
The library item ID (UUID) |
name |
str |
Display name |
active |
bool |
Whether the profile is active |
profile |
str |
The raw .mobileconfig XML content |
mdm_identifier |
str |
The profile's MDM payload identifier |
created_at |
str |
Creation timestamp |
updated_at |
str |
Last-updated timestamp |
runs_on_mac |
bool |
Runs on macOS |
runs_on_iphone |
bool |
Runs on iPhone |
runs_on_ipad |
bool |
Runs on iPad |
runs_on_tv |
bool |
Runs on Apple TV |
runs_on_vision |
bool |
Runs on Apple Vision Pro |
runs_on_android |
bool |
Runs on Android |
runs_on_windows |
bool |
Runs on Windows |
Listed profiles are returned in a PayloadList with count and results properties.
with CustomProfilesResource(config) as profiles:
for profile in profiles.list().results:
state = "active" if profile.active else "inactive"
print(f"{profile.id} {profile.name} ({state})")with CustomProfilesResource(config) as profiles:
profile = profiles.get("54bef6b3-b25e-44b4-89fd-d528d73939e4")
print(profile.name)
print(profile.profile) # the .mobileconfig XMLProvide a name, the profile content as a .mobileconfig file, and at least one target
platform. The file argument accepts either a pathlib.Path or an open binary file object
(BufferedReader).
The create method returns the created profile, including the id.
with CustomProfilesResource(config) as profiles:
created = profiles.create(
name="WiFi Settings",
file=Path("profiles/WiFi/profile.mobileconfig"),
active=True,
runs_on_mac=True,
runs_on_iphone=True,
)
print(f"Created {created.name} ({created.id})")Important
At least one runs_on_* argument must be True, or create() raises ValueError. If
file is a Path that doesn't exist, create() raises FileNotFoundError.
Platform flags default to "leave unset," so only the ones you pass take effect:
| Argument | Platform |
|---|---|
runs_on_mac |
macOS |
runs_on_iphone |
iPhone |
runs_on_ipad |
iPad |
runs_on_tv |
Apple TV |
runs_on_vision |
Apple Vision Pro |
Pass only the fields you want to change. To replace the profile's content, pass a new file.
with CustomProfilesResource(config) as profiles:
# Activate an existing profile.
updated = profiles.update("54bef6b3-b25e-44b4-89fd-d528d73939e4", active=True)
print(f"Updated {updated.name} ({updated.id})")
print(f"active={updated.active}")
# Replace its content.
profiles.update(
"54bef6b3-b25e-44b4-89fd-d528d73939e4",
file=Path("profiles/WiFi/profile.mobileconfig"),
)Deleting a profile only requires the id and does not return anything.
with CustomProfilesResource(config) as profiles:
profiles.delete("54bef6b3-b25e-44b4-89fd-d528d73939e4")- Custom Profiles — the on-disk repository format for profiles.
- Blueprints — assign a profile to a Blueprint after creating it.
Getting Started
Working with Resources
- Populating Your Local Repository
- Editing Resources
- Self Service
- Pushing and Syncing
- Listing and Showing Resources
- Deleting Resources
- Blueprint Assignment
Reference
Python API Client