class AccountApi

Class AccountApi

Entry point class for all account and provisioning API actions: Manage users, cloud names and user groups.

Methods

__construct(ProvisioningConfiguration $configuration = null)

AccountApi constructor.

user(string $userId)

Gets details of a specific user.

users(bool $pending = null, array $userIds = [], string $prefix = null, string $subAccountId = null)

Gets a list of the users according to filters.

createUser(string $name, string $email, string $role, array $subAccountIds = [])

Creates a new user.

updateUser(string $userId, string $name, string $email, string $role, array $subAccountIds = [])

Updates an existing user.

deleteUser(string $userId)

Deletes a user.

subAccounts(bool $enabled = null, array $ids = [], string $prefix = null)

Lists all sub accounts.

createSubAccount(string $name, string $cloudName = null, array $customAttributes = null, bool $enabled = null, string $baseAccount = null)

Creates a new sub account.

deleteSubAccount(string $subAccountId)

Deletes a sub account.

subAccount(string $subAccountId)

Gets information of a sub account.

updateSubAccount(string $subAccountId, string $name = null, string $cloudName = null, array $customAttributes = null, bool $enabled = null)

Updates a sub account.

createUserGroup(string $name)

Creates a new user group.

updateUserGroup(string $groupId, string $name)

Updates an existing user group.

deleteUserGroup(string $groupId)

Deletes a user group.

userGroup(string $groupId)

Gets details of a group.

userGroups()

Gets a list of all the user groups.

addUserToGroup(string $groupId, string $userId)

Adds an existing user to a group.

removeUserFromGroup(string $groupId, string $userId)

Removes a user from a group.

userGroupUsers(string $groupId)

Gets a user list belonging to a user group.

Details

__construct(ProvisioningConfiguration $configuration = null)

AccountApi constructor.

Parameters

Name Type Description
$configuration ProvisioningConfiguration

ApiResponse user(string $userId)

Gets details of a specific user.

Parameters

Name Type Description
$userId string The id of the user to fetch.

Return Value

ApiResponse Details of the user.

ApiResponse users(bool $pending = null, array $userIds = [], string $prefix = null, string $subAccountId = null)

Gets a list of the users according to filters.

Parameters

Name Type Description
$pending bool Whether to fetch pending users. Default all.
$userIds array List of user IDs. Up to 100.
$prefix string Search by prefix of the user's name or email. Case-insensitive.
$subAccountId string Return only users who have access to the given sub-account.

Return Value

ApiResponse List of users associated with the account.

ApiResponse createUser(string $name, string $email, string $role, array $subAccountIds = [])

Creates a new user.

Parameters

Name Type Description
$name string Username.
$email string User's email.
$role string User's role.
$subAccountIds array Sub-accounts for which the user should have access. If not provided or empty, user should have access to all accounts.

Return Value

ApiResponse Details of created user.

ApiResponse updateUser(string $userId, string $name, string $email, string $role, array $subAccountIds = [])

Updates an existing user.

Parameters

Name Type Description
$userId string The id of the user to update.
$name string Username.
$email string User's email.
$role string User's role.
$subAccountIds array Sub-accounts for which the user should have access. If not provided or empty, user should have access to all accounts.

Return Value

ApiResponse The updated user details.

Exceptions

ApiError

ApiResponse deleteUser(string $userId)

Deletes a user.

Parameters

Name Type Description
$userId string Id of the user to delete.

Return Value

ApiResponse Result message.

Exceptions

ApiError

ApiResponse subAccounts(bool $enabled = null, array $ids = [], string $prefix = null)

Lists all sub accounts.

Parameters

Name Type Description
$enabled bool Whether to only return enabled sub-accounts (true) or disabled accounts (false). Default: all accounts are returned (both enabled and disabled).
$ids array List of sub-account IDs. Up to 100. When provided, other filters are ignored.
$prefix string Search by prefix of the sub-account name. Case-insensitive.

Return Value

ApiResponse A list of sub accounts

ApiResponse createSubAccount(string $name, string $cloudName = null, array $customAttributes = null, bool $enabled = null, string $baseAccount = null)

Creates a new sub account.

Parameters

Name Type Description
$name string Name of the new sub account.
$cloudName string A case-insensitive cloud name comprised of alphanumeric and underscore. characters. Generates an error if the cloud name is not unique across all Cloudinary accounts.
$customAttributes array Any custom attributes you want to associate with the sub-account.
$enabled bool Whether to create the account as enabled (default is enabled).
$baseAccount string ID of sub-account from which to copy settings.

Return Value

ApiResponse The created sub account.

ApiResponse deleteSubAccount(string $subAccountId)

Deletes a sub account.

Parameters

Name Type Description
$subAccountId string The id of the sub account.

Return Value

ApiResponse The message.

Exceptions

ApiError

ApiResponse subAccount(string $subAccountId)

Gets information of a sub account.

Parameters

Name Type Description
$subAccountId string The id of the sub account.

Return Value

ApiResponse A sub account.

ApiResponse updateSubAccount(string $subAccountId, string $name = null, string $cloudName = null, array $customAttributes = null, bool $enabled = null)

Updates a sub account.

Parameters

Name Type Description
$subAccountId string The id of the sub account.
$name string The name displayed in the management console.
$cloudName string The cloud name to set.
$customAttributes array Custom attributes associated with the sub-account, as a map of key/value pairs.
$enabled bool Set the sub-account as enabled or not.

Return Value

ApiResponse

Exceptions

ApiError

ApiResponse createUserGroup(string $name)

Creates a new user group.

Parameters

Name Type Description
$name string Name for the group.

Return Value

ApiResponse The newly created group.

ApiResponse updateUserGroup(string $groupId, string $name)

Updates an existing user group.

Parameters

Name Type Description
$groupId string The id of the group to update.
$name string The name of the group.

Return Value

ApiResponse The updated group.

Exceptions

ApiError

ApiResponse deleteUserGroup(string $groupId)

Deletes a user group.

Parameters

Name Type Description
$groupId string The group id to delete.

Return Value

ApiResponse A result message.

Exceptions

ApiError

ApiResponse userGroup(string $groupId)

Gets details of a group.

Parameters

Name Type Description
$groupId string The group id to fetch.

Return Value

ApiResponse Details of the group.

ApiResponse userGroups()

Gets a list of all the user groups.

Return Value

ApiResponse The list of the groups.

ApiResponse addUserToGroup(string $groupId, string $userId)

Adds an existing user to a group.

Parameters

Name Type Description
$groupId string The group id.
$userId string The user id to add.

Return Value

ApiResponse A list of users in the group.

ApiResponse removeUserFromGroup(string $groupId, string $userId)

Removes a user from a group.

Parameters

Name Type Description
$groupId string The group id.
$userId string The id of the user to remove.

Return Value

ApiResponse A list of users in the group.

Exceptions

ApiError

ApiResponse userGroupUsers(string $groupId)

Gets a user list belonging to a user group.

Parameters

Name Type Description
$groupId string The id of the user group.

Return Value

ApiResponse A list of users in that group.