Documentation
¶
Index ¶
- Constants
- Variables
- func IsAlreadyExistsError(err error) bool
- func IsNotFoundError(err error) bool
- func WithFreshReads(ctx context.Context) context.Context
- type Account
- type AccountsResponse
- type BaseAccount
- type BaseType
- type BootPartitionEncryptionDetails
- type Client
- func (c *Client) AddUserGroupMembers(ctx context.Context, groupID int, userIDs []int) (annotations.Annotations, error)
- func (c *Client) CreateUser(ctx context.Context, name, fullName, email string) (annotations.Annotations, error)
- func (c *Client) CreateUserAccount(ctx context.Context, account UserAccountCreateBody) (annotations.Annotations, error)
- func (c *Client) DeleteUser(ctx context.Context, userID int) (annotations.Annotations, error)
- func (c *Client) DeleteUserAccount(ctx context.Context, accountID int) (annotations.Annotations, error)
- func (c *Client) GetBaseAccounts(ctx context.Context) (*BaseAccount, annotations.Annotations, error)
- func (c *Client) GetBaseUserGroups(ctx context.Context) ([]UserGroup, annotations.Annotations, error)
- func (c *Client) GetComputerInventoryDetail(ctx context.Context, computerID string) (*ComputerInventory, annotations.Annotations, error)
- func (c *Client) GetComputersInventory(ctx context.Context, pageToken string, pageSize int, sections []string) ([]ComputerInventory, string, annotations.Annotations, error)
- func (c *Client) GetGroupDetails(ctx context.Context, groupId int) (*Group, annotations.Annotations, error)
- func (c *Client) GetMobileDeviceDetail(ctx context.Context, deviceID string) (*MobileDeviceDetail, annotations.Annotations, error)
- func (c *Client) GetMobileDevices(ctx context.Context, pageToken string, pageSize int) ([]MobileDevice, string, annotations.Annotations, error)
- func (c *Client) GetPrivileges(ctx context.Context) (*PrivilegesResponse, annotations.Annotations, error)
- func (c *Client) GetProAccountGroup(ctx context.Context, groupID int) (*ProAccountGroup, annotations.Annotations, error)
- func (c *Client) GetProAccounts(ctx context.Context, filter, pageToken string, pageSize int) ([]ProAccount, string, annotations.Annotations, error)
- func (c *Client) GetProUsers(ctx context.Context, pageToken string, pageSize int) ([]ProUser, string, annotations.Annotations, error)
- func (c *Client) GetProUsersByUsernameOrEmail(ctx context.Context, values []string) ([]ProUser, annotations.Annotations, error)
- func (c *Client) GetSiteObjects(ctx context.Context, siteID int, objectType, pageToken string) ([]SiteObject, string, annotations.Annotations, error)
- func (c *Client) GetSites(ctx context.Context) (*[]Site, annotations.Annotations, error)
- func (c *Client) GetTokenDetails(ctx context.Context) (*TokenDetails, annotations.Annotations, error)
- func (c *Client) GetUserAccountByName(ctx context.Context, name string) (*UserAccount, annotations.Annotations, error)
- func (c *Client) GetUserAccountDetails(ctx context.Context, userId int) (*UserAccount, annotations.Annotations, error)
- func (c *Client) GetUserByName(ctx context.Context, name string) (*User, annotations.Annotations, error)
- func (c *Client) GetUserDetails(ctx context.Context, userId int) (*User, annotations.Annotations, error)
- func (c *Client) GetUserGroupDetails(ctx context.Context, userGroupId int) (*UserGroup, annotations.Annotations, error)
- func (c *Client) RemoveUserGroupMembers(ctx context.Context, groupID int, userIDs []int) (annotations.Annotations, error)
- func (c *Client) SetComputerAssignedUser(ctx context.Context, computerID string, fields ComputerAssignedUserFields) (annotations.Annotations, error)
- func (c *Client) SetMobileDeviceAssignedUser(ctx context.Context, deviceID string, username string) (annotations.Annotations, error)
- func (c *Client) UpdateAccountPrivileges(ctx context.Context, accountID int, name, privilegeSet string, ...) (annotations.Annotations, error)
- func (c *Client) UpdateGroupMembers(ctx context.Context, groupID int, name string, members []BaseType) (annotations.Annotations, error)
- func (c *Client) UpdateGroupPrivileges(ctx context.Context, groupID int, name, privilegeSet string, ...) (annotations.Annotations, error)
- func (c *Client) UpdateUserSites(ctx context.Context, userID int, sites UserSites) (annotations.Annotations, error)
- type ComputerAssignedUserFields
- type ComputerDiskEncryption
- type ComputerGeneral
- type ComputerHardware
- type ComputerInventory
- type ComputerMDMCapable
- type ComputerOperatingSystem
- type ComputerRemoteManagement
- type ComputerSecurity
- type ComputerUserAndLocation
- type ComputersInventoryResponse
- type ErrorResponse
- type Group
- type GroupMembersUpdateBody
- type GroupResponse
- type MobileDevice
- type MobileDeviceDetail
- type MobileDeviceLocation
- type MobileDevicesResponse
- type NamedRef
- type Privileges
- type PrivilegesResponse
- type ProAccount
- type ProAccountGroup
- type ProAccountsResponse
- type ProUser
- type ProUsersResponse
- type Site
- type SiteObject
- type SitesResponse
- type TokenDetails
- type TokenResponse
- type TokenSource
- type User
- type UserAccount
- type UserAccountCreateBody
- type UserAccountResponse
- type UserCreateBody
- type UserGroup
- type UserGroupMemberMutation
- type UserGroupResponse
- type UserGroupsResponse
- type UserResponse
- type UserSites
- type UserSitesUpdateBody
Constants ¶
const ( // UsersPageSize is the documented maximum page-size of GET /api/v1/users. UsersPageSize = 1000 // AccountsPageSize is the documented default page-size of GET /api/v1/accounts; no maximum is documented. AccountsPageSize = 100 // SiteObjectsPageSize is the page-size used for GET /api/v1/sites/{id}/objects; no maximum is documented. SiteObjectsPageSize = 1000 )
Variables ¶
var ComputerAssigneeSections = []string{"USER_AND_LOCATION"}
ComputerAssigneeSections is the only section the grants pass reads: the assignee.
var ComputerInventorySections = []string{
"GENERAL",
"HARDWARE",
"OPERATING_SYSTEM",
"DISK_ENCRYPTION",
"SECURITY",
}
ComputerInventorySections are the sections List requests from the v4 list endpoint, which returns only the requested sections (only GENERAL when none is sent).
Functions ¶
func IsAlreadyExistsError ¶ added in v0.0.12
IsAlreadyExistsError reports whether err carries the gRPC AlreadyExists code, which this package maps from an HTTP 409, e.g. creating a user/account with a name that's already taken. Jamf also returns 409 for plain validation failures (malformed fields, invalid references), so a 409 is not proof the resource already exists — only treat it that way where the operation's semantics make "already exists" the sole realistic cause.
func IsNotFoundError ¶ added in v0.0.12
IsNotFoundError reports whether err carries the gRPC NotFound code, which this package maps from an HTTP 404, e.g. deleting a user/account that no longer exists.
func WithFreshReads ¶ added in v0.1.2
WithFreshReads returns a context that causes GET requests issued through this client to bypass the response cache. Provisioning entry points (Grant, Revoke, CreateAccount, Delete) wrap their ctx with this at the top of the method; sync code paths (List, Entitlements, Grants) must not, so they keep benefiting from the cache.
Types ¶
type Account ¶
type Account struct {
ID string `json:"id"`
Username string `json:"username"`
RealName string `json:"realName"`
Email string `json:"email"`
MultiSiteAdmin bool `json:"multiSiteAdmin"`
AccessLevel string `json:"accessLevel"`
PrivilegeSet string `json:"privilegeSet"`
CurrentSiteID string `json:"currentSiteId"`
}
type AccountsResponse ¶ added in v0.0.4
type AccountsResponse struct {
Accounts BaseAccount `json:"accounts"`
}
type BaseAccount ¶
type BootPartitionEncryptionDetails ¶ added in v0.0.11
type BootPartitionEncryptionDetails struct {
PartitionName string `json:"partitionName"`
PartitionFileVault2State string `json:"partitionFileVault2State"`
}
BootPartitionEncryptionDetails reports the FileVault 2 state of the boot partition. partitionFileVault2State is an enum string (e.g. ENCRYPTED / UNENCRYPTED / DECRYPTED / ...).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(wrapper *uhttp.BaseHttpClient, instanceURL string, tokenSource *TokenSource) (*Client, error)
NewClient validates instanceURL and returns a client that authenticates with tokenSource.
func (*Client) AddUserGroupMembers ¶ added in v0.1.2
func (c *Client) AddUserGroupMembers(ctx context.Context, groupID int, userIDs []int) (annotations.Annotations, error)
AddUserGroupMembers adds the given user IDs to a static Jamf user group via the additions verb (PUT .../usergroups/id/{id} <user_group><user_additions>). Atomic — no read-modify-write. Returns a gRPC NotFound error if the group doesn't exist (surfaced via IsNotFoundError).
func (*Client) CreateUser ¶ added in v0.0.12
func (c *Client) CreateUser(ctx context.Context, name, fullName, email string) (annotations.Annotations, error)
CreateUser creates a new Jamf user with POST /JSSResource/users/id/0. Jamf answers 409 (AlreadyExists) for a taken name and for other rejected creates, so a duplicate is only confirmed by looking the user up.
func (*Client) CreateUserAccount ¶ added in v0.0.12
func (c *Client) CreateUserAccount(ctx context.Context, account UserAccountCreateBody) (annotations.Annotations, error)
CreateUserAccount creates a new Jamf Pro console admin account with POST /JSSResource/accounts/userid/0. Jamf answers 409 (AlreadyExists) for a taken name and for other rejected creates, so a duplicate is only confirmed by looking the account up.
func (*Client) DeleteUser ¶ added in v0.0.12
func (c *Client) DeleteUser(ctx context.Context, userID int) (annotations.Annotations, error)
DeleteUser deletes a Jamf user with DELETE /api/v1/users/{id}, which needs the Delete User privilege. Only a 404 with Jamf's NOT_FOUND code is NotFound; any other 404 means this Jamf Pro lacks the endpoint.
func (*Client) DeleteUserAccount ¶ added in v0.0.12
func (c *Client) DeleteUserAccount(ctx context.Context, accountID int) (annotations.Annotations, error)
DeleteUserAccount deletes a Jamf admin account with DELETE /api/v1/accounts/{id}, which needs the Delete Accounts privilege. Only a 404 with Jamf's INVALID_ID code is NotFound; any other 404 means this Jamf Pro lacks the endpoint.
func (*Client) GetBaseAccounts ¶ added in v0.2.5
func (c *Client) GetBaseAccounts(ctx context.Context) (*BaseAccount, annotations.Annotations, error)
GetBaseAccounts returns the Classic admin accounts (users and groups, id and name only). GET /JSSResource/accounts, not paginated, needs the Read Accounts privilege.
func (*Client) GetBaseUserGroups ¶ added in v0.2.5
func (c *Client) GetBaseUserGroups(ctx context.Context) ([]UserGroup, annotations.Annotations, error)
GetBaseUserGroups returns the Classic user groups (id and name only). GET /JSSResource/usergroups, not paginated, needs the Read Static User Groups privilege.
func (*Client) GetComputerInventoryDetail ¶ added in v0.1.2
func (c *Client) GetComputerInventoryDetail(ctx context.Context, computerID string) (*ComputerInventory, annotations.Annotations, error)
GetComputerInventoryDetail fetches a computer's current inventory detail. Grant and Revoke read it first since the device may have been reassigned since last sync.
func (*Client) GetComputersInventory ¶ added in v0.0.11
func (c *Client) GetComputersInventory(ctx context.Context, pageToken string, pageSize int, sections []string) ([]ComputerInventory, string, annotations.Annotations, error)
GetComputersInventory returns one page of computers ordered by id, holding only the requested sections, and the next page token, "" after the last page. GET /api/v4/computers-inventory, needs the Read Computers privilege.
func (*Client) GetGroupDetails ¶
func (c *Client) GetGroupDetails(ctx context.Context, groupId int) (*Group, annotations.Annotations, error)
GetGroupDetails returns Jamf group details.
func (*Client) GetMobileDeviceDetail ¶ added in v0.1.2
func (c *Client) GetMobileDeviceDetail(ctx context.Context, deviceID string) (*MobileDeviceDetail, annotations.Annotations, error)
GetMobileDeviceDetail fetches a mobile device's detail record, used by Grant and Revoke for the same reassignment check as GetComputerInventoryDetail. Unlike the plain GET endpoint (flat top-level username), the detail response nests it under location.username; the two values agree.
func (*Client) GetMobileDevices ¶ added in v0.0.11
func (c *Client) GetMobileDevices(ctx context.Context, pageToken string, pageSize int) ([]MobileDevice, string, annotations.Annotations, error)
GetMobileDevices returns one page of mobile devices ordered by id and the next page token, "" after the last page. GET /api/v2/mobile-devices, needs the Read Mobile Devices privilege.
func (*Client) GetPrivileges ¶ added in v0.0.8
func (c *Client) GetPrivileges(ctx context.Context) (*PrivilegesResponse, annotations.Annotations, error)
func (*Client) GetProAccountGroup ¶ added in v0.2.8
func (c *Client) GetProAccountGroup(ctx context.Context, groupID int) (*ProAccountGroup, annotations.Annotations, error)
GetProAccountGroup returns an admin group's name and members with GET /api/v1/account-groups/{id} (Read Account Groups). Only a 404 with Jamf's INVALID_ID code is NotFound; any other 404 means this Jamf Pro lacks the endpoint.
func (*Client) GetProAccounts ¶ added in v0.2.5
func (c *Client) GetProAccounts(ctx context.Context, filter, pageToken string, pageSize int) ([]ProAccount, string, annotations.Annotations, error)
GetProAccounts returns one page of admin accounts ordered by id and the next page token, "" after the last page. filter is an optional RSQL expression. GET /api/v1/accounts, needs the Read Accounts privilege.
func (*Client) GetProUsers ¶ added in v0.2.5
func (c *Client) GetProUsers(ctx context.Context, pageToken string, pageSize int) ([]ProUser, string, annotations.Annotations, error)
GetProUsers returns one page of users ordered by id and the next page token, "" after the last page. GET /api/v1/users, needs the Read User privilege.
func (*Client) GetProUsersByUsernameOrEmail ¶ added in v0.2.5
func (c *Client) GetProUsersByUsernameOrEmail(ctx context.Context, values []string) ([]ProUser, annotations.Annotations, error)
GetProUsersByUsernameOrEmail returns up to UsersPageSize users, ordered by id, whose username or email equals any of values. GET /api/v1/users with an RSQL filter, needs the Read User privilege. RSQL treats `*` as a wildcard, so the caller must re-check each match.
func (*Client) GetSiteObjects ¶ added in v0.2.5
func (c *Client) GetSiteObjects(ctx context.Context, siteID int, objectType, pageToken string) ([]SiteObject, string, annotations.Annotations, error)
GetSiteObjects returns one page of the site's objects of objectType (for example "User") and the next page token, "" once a page comes back empty. GET /api/v1/sites/{id}/objects, needs the Read Sites privilege. An unknown site answers an empty list, so a 404 means the instance lacks the endpoint.
func (*Client) GetSites ¶
func (c *Client) GetSites(ctx context.Context) (*[]Site, annotations.Annotations, error)
GetSites returns all Jamf sites.
func (*Client) GetTokenDetails ¶
func (c *Client) GetTokenDetails(ctx context.Context) (*TokenDetails, annotations.Annotations, error)
GetTokenDetails gets authorization details associated with the current api token.
func (*Client) GetUserAccountByName ¶ added in v0.0.12
func (c *Client) GetUserAccountByName(ctx context.Context, name string) (*UserAccount, annotations.Annotations, error)
GetUserAccountByName returns the Jamf admin account with the given username.
func (*Client) GetUserAccountDetails ¶
func (c *Client) GetUserAccountDetails(ctx context.Context, userId int) (*UserAccount, annotations.Annotations, error)
GetUserAccountDetails returns Jamf user account details; a 404 (IsNotFoundError) means the account does not exist.
func (*Client) GetUserByName ¶ added in v0.0.12
func (c *Client) GetUserByName(ctx context.Context, name string) (*User, annotations.Annotations, error)
GetUserByName returns the Jamf user with the given username (login name).
func (*Client) GetUserDetails ¶ added in v0.1.2
func (c *Client) GetUserDetails(ctx context.Context, userId int) (*User, annotations.Annotations, error)
GetUserDetails returns Jamf user details for a single directory user.
func (*Client) GetUserGroupDetails ¶
func (c *Client) GetUserGroupDetails(ctx context.Context, userGroupId int) (*UserGroup, annotations.Annotations, error)
GetUserGroupDetails returns Jamf user group details.
func (*Client) RemoveUserGroupMembers ¶ added in v0.1.2
func (c *Client) RemoveUserGroupMembers(ctx context.Context, groupID int, userIDs []int) (annotations.Annotations, error)
RemoveUserGroupMembers removes the given user IDs from a static Jamf user group via the deletions verb (<user_group><user_deletions>). Atomic. Returns a gRPC NotFound error if the group doesn't exist (surfaced via IsNotFoundError).
func (*Client) SetComputerAssignedUser ¶ added in v0.1.2
func (c *Client) SetComputerAssignedUser(ctx context.Context, computerID string, fields ComputerAssignedUserFields) (annotations.Annotations, error)
SetComputerAssignedUser sets (Grant) or clears (Revoke, zero-value fields) the assigned user on a computer's inventory record — see ComputerAssignedUserFields for the field semantics.
func (*Client) SetMobileDeviceAssignedUser ¶ added in v0.1.2
func (c *Client) SetMobileDeviceAssignedUser(ctx context.Context, deviceID string, username string) (annotations.Annotations, error)
SetMobileDeviceAssignedUser is the mobile-device equivalent, via location.username — see MobileDeviceLocation for the field semantics. The Classic PUT is deliberately not used here: it writes the device's leftover location values back into the directory user's own record.
func (*Client) UpdateAccountPrivileges ¶ added in v0.1.2
func (c *Client) UpdateAccountPrivileges(ctx context.Context, accountID int, name, privilegeSet string, privileges *Privileges) (annotations.Annotations, error)
UpdateAccountPrivileges updates a Jamf admin account's privilege_set and/or individual privileges. See https://developer.jamf.com/jamf-pro/reference/updateaccountbyid.
func (*Client) UpdateGroupMembers ¶ added in v0.1.2
func (c *Client) UpdateGroupMembers(ctx context.Context, groupID int, name string, members []BaseType) (annotations.Annotations, error)
UpdateGroupMembers updates a Jamf access-level group's membership via a minimal PUT carrying only <name> and <members> — see GroupMembersUpdateBody. members is the complete desired list; pass an empty slice to clear the last member. Returns a gRPC NotFound error (IsNotFoundError) if the group doesn't exist. See https://developer.jamf.com/jamf-pro/reference/updategroupbyid.
func (*Client) UpdateGroupPrivileges ¶ added in v0.1.2
func (c *Client) UpdateGroupPrivileges(ctx context.Context, groupID int, name, privilegeSet string, privileges *Privileges) (annotations.Annotations, error)
UpdateGroupPrivileges is UpdateAccountPrivileges's counterpart for an admin account group. See https://developer.jamf.com/jamf-pro/reference/updategroupbyid.
func (*Client) UpdateUserSites ¶ added in v0.1.2
func (c *Client) UpdateUserSites(ctx context.Context, userID int, sites UserSites) (annotations.Annotations, error)
UpdateUserSites PUTs the full desired <sites> list for a user, leaving the rest of the user record untouched (Classic API field-level merge). Callers own the read-modify-write and idempotency checks (see site.go).
Concurrency note: no locking/versioning guard — concurrent calls for the same userID can race and silently drop one side's change; serialize calls per user if that matters.
type ComputerAssignedUserFields ¶ added in v0.1.2
type ComputerAssignedUserFields struct {
Username string `json:"username"`
Realname string `json:"realname"`
Email string `json:"email"`
Position string `json:"position"`
Phone string `json:"phone"`
}
ComputerAssignedUserFields is the assignee-identity subset of a computer's userAndLocation that Grant/Revoke write: username, realname, email, position and phone. "" clears a field, an omitted key is a no-op, and the keys are independent, so all five are always sent as plain strings (no `omitempty`). Grant populates every field from the new assignee's Jamf user record, overwriting whatever the previous assignee left behind since Jamf never auto-populates these for computers; Revoke sends the zero value of this struct to clear all five.
type ComputerDiskEncryption ¶ added in v0.0.11
type ComputerDiskEncryption struct {
BootPartitionEncryptionDetails *BootPartitionEncryptionDetails `json:"bootPartitionEncryptionDetails"`
}
ComputerDiskEncryption holds the DISK_ENCRYPTION section.
type ComputerGeneral ¶ added in v0.0.11
type ComputerGeneral struct {
Name string `json:"name"`
LastEnrolledDate string `json:"lastEnrolledDate"`
Supervised bool `json:"supervised"`
MDMCapable *ComputerMDMCapable `json:"mdmCapable"`
RemoteManagement *ComputerRemoteManagement `json:"remoteManagement"`
Site *NamedRef `json:"site"`
}
ComputerGeneral holds the GENERAL section.
type ComputerHardware ¶ added in v0.0.11
type ComputerHardware struct {
Make string `json:"make"`
Model string `json:"model"`
ModelIdentifier string `json:"modelIdentifier"`
SerialNumber string `json:"serialNumber"`
}
ComputerHardware holds the HARDWARE section.
type ComputerInventory ¶ added in v0.0.11
type ComputerInventory struct {
ID string `json:"id"`
UDID string `json:"udid"`
General *ComputerGeneral `json:"general"`
Hardware *ComputerHardware `json:"hardware"`
OperatingSystem *ComputerOperatingSystem `json:"operatingSystem"`
UserAndLocation *ComputerUserAndLocation `json:"userAndLocation"`
DiskEncryption *ComputerDiskEncryption `json:"diskEncryption"`
Security *ComputerSecurity `json:"security"`
}
ComputerInventory is a single computer record. Each section is a pointer since it may be absent from a given response.
type ComputerMDMCapable ¶ added in v0.0.11
type ComputerMDMCapable struct {
Capable bool `json:"capable"`
}
ComputerMDMCapable reports whether the device can be managed via MDM.
type ComputerOperatingSystem ¶ added in v0.0.11
type ComputerOperatingSystem struct {
Name string `json:"name"`
Version string `json:"version"`
Build string `json:"build"`
}
ComputerOperatingSystem holds the OPERATING_SYSTEM section.
type ComputerRemoteManagement ¶ added in v0.0.11
type ComputerRemoteManagement struct {
Managed bool `json:"managed"`
}
ComputerRemoteManagement reports whether the device is currently managed.
type ComputerSecurity ¶ added in v0.0.11
type ComputerSecurity struct {
SipStatus string `json:"sipStatus"`
GatekeeperStatus string `json:"gatekeeperStatus"`
ActivationLockEnabled bool `json:"activationLockEnabled"`
RecoveryLockEnabled bool `json:"recoveryLockEnabled"`
FirewallEnabled bool `json:"firewallEnabled"`
SecureBootLevel string `json:"secureBootLevel"`
ExternalBootLevel string `json:"externalBootLevel"`
}
ComputerSecurity holds the SECURITY section.
type ComputerUserAndLocation ¶ added in v0.0.11
type ComputerUserAndLocation struct {
Username string `json:"username"`
Realname string `json:"realname"`
Email string `json:"email"`
EmailAddress string `json:"emailAddress"`
Position string `json:"position"`
Phone string `json:"phone"`
DepartmentID string `json:"departmentId"`
BuildingID string `json:"buildingId"`
Room string `json:"room"`
}
ComputerUserAndLocation holds the USER_AND_LOCATION section. v4 only returns `email`; EmailAddress has no v4 key but is kept for EmailAddr's fallback.
func (*ComputerUserAndLocation) EmailAddr ¶ added in v0.0.11
func (u *ComputerUserAndLocation) EmailAddr() string
EmailAddr returns whichever email field Jamf populated.
type ComputersInventoryResponse ¶ added in v0.0.11
type ComputersInventoryResponse struct {
TotalCount int `json:"totalCount"`
Results []ComputerInventory `json:"results"`
}
ComputersInventoryResponse is the paginated envelope returned by GET /api/v4/computers-inventory.
type ErrorResponse ¶ added in v0.2.5
type ErrorResponse struct {
HTTPStatus int `json:"httpStatus"`
Errors []struct {
Code string `json:"code"`
Description string `json:"description"`
} `json:"errors"`
}
ErrorResponse is the Jamf Pro API error body. The Classic API answers errors with an HTML page.
func (*ErrorResponse) Message ¶ added in v0.2.5
func (e *ErrorResponse) Message() string
type Group ¶
type Group struct {
BaseType
AccessLevel string `json:"access_level"`
// PrivilegeSet can take the following values:
//
// - "Administrator"
//
// - "Auditor"
//
// - "Enrollment Only"
//
// - "Custom"
PrivilegeSet string `json:"privilege_set"`
Privileges Privileges `json:"privileges"`
Site BaseType `json:"site"`
Members []BaseType `json:"members"`
}
type GroupMembersUpdateBody ¶ added in v0.1.2
type GroupMembersUpdateBody struct {
XMLName xml.Name `xml:"group"`
Name string `xml:"name"`
Members *memberUsers `xml:"members"`
}
GroupMembersUpdateBody is the minimal XML PUT body for /JSSResource/accounts/groupid/{id} used for membership-only changes (see Client.UpdateGroupMembers). It carries only name and members: access_level, privilege_set and site are left untouched when omitted, so they are deliberately not fields on this type at all. Resending a zero site would make Jamf reject the request with a 409, so site is never sent here.
Members is a pointer so an explicit empty <members></members> can be forced when the last member is being removed: a nil slice under `xml:"members>user"` would omit the element entirely, which Jamf interprets as "leave members unchanged" rather than "clear members".
type GroupResponse ¶ added in v0.0.4
type GroupResponse struct {
Group Group `json:"group"`
}
type MobileDevice ¶ added in v0.0.11
type MobileDevice struct {
ID string `json:"id"`
Name string `json:"name"`
SerialNumber string `json:"serialNumber"`
UDID string `json:"udid"`
Model string `json:"model"`
ModelIdentifier string `json:"modelIdentifier"`
Username string `json:"username"`
Type string `json:"type"`
Managed bool `json:"managed"`
Supervised bool `json:"supervised"`
OSVersion string `json:"osVersion"`
OSBuild string `json:"osBuild"`
WifiMacAddress string `json:"wifiMacAddress"`
PhoneNumber string `json:"phoneNumber"`
}
MobileDevice is a single mobile-device record from the v2 list endpoint. The list endpoint returns a flat, limited field set (the per-device detail endpoint carries more); only the flat fields are modeled here.
type MobileDeviceDetail ¶ added in v0.1.2
type MobileDeviceDetail struct {
ID string `json:"id"`
Location *MobileDeviceLocation `json:"location"`
}
MobileDeviceDetail is a single mobile-device record from the v2 detail endpoint. Only the location section needed to resolve the device's current assignee is modeled here.
type MobileDeviceLocation ¶ added in v0.1.2
type MobileDeviceLocation struct {
Username string `json:"username"`
}
MobileDeviceLocation holds the `location` section of a mobile-device detail record (read), and doubles as the PATCH body's location payload (write — see SetMobileDeviceAssignedUser): setting Username makes Jamf auto-populate realname/email/position/phone from the directory user, and a nonexistent username is accepted by auto-creating one, so the connector never has (or needs) those fields to send here. "" clears the username and every auto-populated field together; null/{} are silent no-ops, so Revoke must always send an explicit "" rather than omitting the field.
type MobileDevicesResponse ¶ added in v0.0.11
type MobileDevicesResponse struct {
TotalCount int `json:"totalCount"`
Results []MobileDevice `json:"results"`
}
MobileDevicesResponse is the paginated envelope returned by GET /api/v2/mobile-devices.
type NamedRef ¶ added in v0.0.11
NamedRef is a generic {id,name} reference used by several Jamf sections.
type Privileges ¶ added in v0.0.8
type Privileges struct {
JSSObjects []string `json:"jss_objects" xml:"jss_objects>privilege,omitempty"`
JSSSettings []string `json:"jss_settings" xml:"jss_settings>privilege,omitempty"`
JSSActions []string `json:"jss_actions" xml:"jss_actions>privilege,omitempty"`
Recon []string `json:"recon" xml:"recon>privilege,omitempty"`
CasperAdmin []string `json:"casper_admin" xml:"casper_admin>privilege,omitempty"`
CasperRemote []string `json:"casper_remote" xml:"casper_remote>privilege,omitempty"`
CasperImaging []string `json:"casper_imaging" xml:"casper_imaging>privilege,omitempty"`
}
Privileges models the Classic API's <privileges> block: the privileges a Custom privilege_set was given, or on reads, a built-in set's privileges already expanded. Each category is a list of privilege names.
func (*Privileges) All ¶ added in v0.2.5
func (p *Privileges) All() []string
All returns every privilege name of p.
func (*Privileges) Contains ¶ added in v0.0.13
func (p *Privileges) Contains(privilege string) bool
Contains reports whether privilege appears in any of p's 7 categories.
func (Privileges) Map ¶ added in v0.1.2
func (p Privileges) Map(fn func([]string) []string) Privileges
Map returns a copy of p with fn applied to each of its 7 categories.
func (Privileges) MarshalXML ¶ added in v0.0.13
func (p Privileges) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML emits only the privilege categories that are populated. encoding/xml's built-in "omitempty" does not apply to a nil/empty slice nested behind a ">"-chained struct tag (e.g. "jss_objects>privilege") — it always emits the empty wrapper element regardless. This method replaces that encoding on the write path so an unset category is omitted rather than sent as "<jss_settings></jss_settings>"; the struct's xml tags remain for decoding (test-server still uses them).
type PrivilegesResponse ¶ added in v0.0.8
type PrivilegesResponse struct {
Privileges []string `json:"privileges"`
}
type ProAccount ¶ added in v0.2.5
type ProAccount struct {
ID int `json:"id,string"`
Username string `json:"username"`
Realname string `json:"realname"`
Email string `json:"email"`
AccountStatus string `json:"accountStatus"`
}
ProAccount is an admin account in the Jamf Pro API accounts list (GET /api/v1/accounts).
func (ProAccount) UserAccount ¶ added in v0.2.5
func (a ProAccount) UserAccount() *UserAccount
UserAccount returns the account in the Classic UserAccount shape, without privileges.
type ProAccountGroup ¶ added in v0.2.8
type ProAccountGroup struct {
Name string `json:"name"`
// Members is nil when the response has no members key.
Members *[]ProAccount `json:"members"`
}
ProAccountGroup is the part of GET /api/v1/account-groups/{id} the connector reads.
type ProAccountsResponse ¶ added in v0.2.5
type ProAccountsResponse struct {
TotalCount int `json:"totalCount"`
Results []ProAccount `json:"results"`
}
type ProUser ¶ added in v0.2.5
type ProUser struct {
ID int `json:"id,string"`
Username string `json:"username"`
Realname string `json:"realname"`
Email string `json:"email"`
}
ProUser is a user in the Jamf Pro API users list (GET /api/v1/users).
type ProUsersResponse ¶ added in v0.2.5
type SiteObject ¶ added in v0.2.5
type SiteObject struct {
ObjectType string `json:"objectType"`
ObjectID int `json:"objectId,string"`
}
SiteObject is an object (user, user group, ...) assigned to a site (GET /api/v1/sites/{id}/objects).
type SitesResponse ¶ added in v0.0.4
type SitesResponse struct {
Sites []Site `json:"sites"`
}
type TokenDetails ¶
type TokenResponse ¶ added in v0.0.4
type TokenSource ¶ added in v0.2.4
type TokenSource struct {
// contains filtered or unexported fields
}
TokenSource reuses a Jamf token until it is about to expire. Renew drops it when Jamf rejects it earlier.
func NewAPIClientTokenSource ¶ added in v0.2.4
func NewAPIClientTokenSource(wrapper *uhttp.BaseHttpClient, instanceURL, clientID, clientSecret string) (*TokenSource, error)
NewAPIClientTokenSource exchanges a Jamf Pro API client's ID and secret for access tokens via POST /api/v1/oauth/token: https://developer.jamf.com/jamf-pro/docs/client-credentials
func NewBasicTokenSource ¶ added in v0.2.4
func NewBasicTokenSource(wrapper *uhttp.BaseHttpClient, instanceURL, username, password string) (*TokenSource, error)
NewBasicTokenSource mints bearer tokens with a local Jamf Pro account's username and password.
func (*TokenSource) Renew ¶ added in v0.2.4
func (s *TokenSource) Renew(rejected string)
Renew drops the cached token only if it is still the rejected one, so concurrent 401s get one new token, not one each.
type User ¶
type User struct {
BaseType
FullName string `json:"full_name"`
Email string `json:"email"`
EmailAddress string `json:"email_address"`
Username string `json:"username"`
Position string `json:"position"`
// PhoneNumber is the Classic API's key for this field (findusersbyid) -
// not "phone", which is the unrelated key Jamf uses for a computer's
// userAndLocation.phone.
PhoneNumber string `json:"phone_number"`
Sites UserSites `json:"sites"`
}
User - end user in Jamf.
func (*User) LoginName ¶ added in v0.1.2
LoginName returns the account's login identifier: Username when set, falling back to Name.
func (*User) PrimaryEmail ¶ added in v0.1.2
PrimaryEmail returns the account's email: Email when set, falling back to EmailAddress.
type UserAccount ¶
type UserAccount struct {
BaseType
FullName string `json:"full_name"`
Email string `json:"email"`
EmailAddress string `json:"email_address"`
Enabled string `json:"enabled"`
AccessLevel string `json:"access_level"`
PrivilegeSet string `json:"privilege_set"`
Privileges Privileges `json:"privileges"`
Site BaseType `json:"site"`
}
UserAccount - user that has access to their system and can be granted permissions.
type UserAccountCreateBody ¶ added in v0.0.12
type UserAccountCreateBody struct {
XMLName xml.Name `xml:"account"`
Name string `xml:"name"`
Password string `xml:"password"`
FullName string `xml:"full_name,omitempty"`
Email string `xml:"email,omitempty"`
Enabled string `xml:"enabled,omitempty"`
AccessLevel string `xml:"access_level,omitempty"`
}
UserAccountCreateBody is the XML request body for POST /JSSResource/accounts/userid/0. The Classic API only accepts XML for POST/PUT requests (JSON is GET-only), so this is marshaled with encoding/xml, not encoding/json.
type UserAccountResponse ¶ added in v0.0.4
type UserAccountResponse struct {
UserAccount UserAccount `json:"account"`
}
type UserCreateBody ¶ added in v0.0.12
type UserCreateBody struct {
XMLName xml.Name `xml:"user"`
Name string `xml:"name"`
FullName string `xml:"full_name,omitempty"`
Email string `xml:"email,omitempty"`
}
UserCreateBody is the XML request body for POST /JSSResource/users/id/0. The Classic API only accepts XML for POST/PUT requests (JSON is GET-only), so this is marshaled with encoding/xml, not encoding/json.
type UserGroupMemberMutation ¶ added in v0.1.2
type UserGroupMemberMutation struct {
XMLName xml.Name `xml:"user_group"`
Additions *memberUsers `xml:"user_additions,omitempty"`
Deletions *memberUsers `xml:"user_deletions,omitempty"`
}
UserGroupMemberMutation is the PUT body for /usergroups/id/{id} that adds or removes individual users from a static group via Jamf's PATCH-like additions/deletions verb. Exactly one of Additions/Deletions is set per call — Grant uses Additions, Revoke uses Deletions.
type UserGroupResponse ¶ added in v0.0.4
type UserGroupResponse struct {
UserGroup UserGroup `json:"user_group"`
}
type UserGroupsResponse ¶ added in v0.0.4
type UserGroupsResponse struct {
UserGroups []UserGroup `json:"user_groups"`
}
type UserResponse ¶ added in v0.0.4
type UserResponse struct {
User User `json:"user"`
}
type UserSites ¶ added in v0.1.2
type UserSites []BaseType
UserSites is the decoded form of a Jamf user's <sites> list. A live Jamf Pro 11.32.1 tenant returns this as a flat list, each entry's id/name at the top level (e.g. {"id":5,"name":"Site A"}), while the Classic API's documented shape wraps each entry under a "site" key (e.g. {"site":{"id":5,"name":"Site A"}}). UnmarshalJSON accepts both so a site's real id is always decoded, regardless of which shape the tenant serves.
func (*UserSites) UnmarshalJSON ¶ added in v0.1.2
type UserSitesUpdateBody ¶ added in v0.1.2
type UserSitesUpdateBody struct {
XMLName xml.Name `xml:"user"`
Sites []BaseType `xml:"sites>site"`
}
UserSitesUpdateBody is the PUT body for /users/id/{id} carrying only the <sites> block. A Classic API PUT only changes the elements it sends, so the rest of the user record (email, full_name, etc.) is left untouched.