Class Account

java.lang.Object
com.cloudinary.provisioning.Account

public class Account
extends java.lang.Object
Entry point class for all account and provisioning API actions: Manage users, cloud names and user groups.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  Account.Role
    A user role to use in the user management API (create/update user).
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String ACCOUNTS  
    static java.lang.String PROVISIONING  
    static java.lang.String USER_GROUPS  
    static java.lang.String USERS  
  • Constructor Summary

    Constructors 
    Constructor Description
    Account​(Cloudinary cloudinary)
    Create a new instance to use the account API.
    Account​(AccountConfiguration accountConfiguration, Cloudinary cloudinary)
    Create a new instance to use the account API.
  • Method Summary

    Modifier and Type Method Description
    ApiResponse addUserToGroup​(java.lang.String groupId, java.lang.String userId)
    Add an existing user to a group.
    ApiResponse addUserToGroup​(java.lang.String groupId, java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Add an existing user to a group.
    ApiResponse createSubAccount​(java.lang.String name, java.lang.String cloudName, java.util.Map customAttributes, boolean enabled, java.lang.String baseAccount)  
    ApiResponse createSubAccount​(java.lang.String name, java.lang.String cloudName, java.util.Map customAttributes, boolean enabled, java.lang.String baseAccount, java.util.Map<java.lang.String,​java.lang.Object> options)  
    ApiResponse createUser​(java.lang.String name, java.lang.String email, Account.Role role, java.lang.Boolean enabled, java.util.List<java.lang.String> subAccountsIds, java.util.Map<java.lang.String,​java.lang.Object> options)
    Create a new user.
    ApiResponse createUser​(java.lang.String name, java.lang.String email, Account.Role role, java.util.List<java.lang.String> subAccountsIds)
    Create a new user.
    ApiResponse createUser​(java.lang.String name, java.lang.String email, Account.Role role, java.util.List<java.lang.String> subAccountsIds, java.util.Map<java.lang.String,​java.lang.Object> options)
    Create a new user.
    ApiResponse createUserGroup​(java.lang.String name)
    Create a new user group
    ApiResponse createUserGroup​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> options)
    Create a new user group
    ApiResponse deleteSubAccount​(java.lang.String subAccountId)
    Deletes the sub-account.
    ApiResponse deleteSubAccount​(java.lang.String subAccountId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Deletes the sub-account.
    ApiResponse deleteUser​(java.lang.String userId)
    Delete a user.
    ApiResponse deleteUser​(java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Delete a user.
    ApiResponse deleteUserGroup​(java.lang.String groupId)
    Delete a user group
    ApiResponse deleteUserGroup​(java.lang.String groupId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Delete a user group
    ApiResponse removeUserFromGroup​(java.lang.String groupId, java.lang.String userId)
    Removes a user from a group.
    ApiResponse removeUserFromGroup​(java.lang.String groupId, java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Removes a user from a group.
    ApiResponse subAccount​(java.lang.String subAccountId)
    Get details of a specific sub account
    ApiResponse subAccount​(java.lang.String subAccountId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Get details of a specific sub account
    ApiResponse subAccounts​(java.lang.Boolean enabled, java.util.List<java.lang.String> ids, java.lang.String prefix)
    Get a list of sub accounts.
    ApiResponse subAccounts​(java.lang.Boolean enabled, java.util.List<java.lang.String> ids, java.lang.String prefix, java.util.Map<java.lang.String,​java.lang.Object> options)
    Get a list of sub accounts.
    ApiResponse updateSubAccount​(java.lang.String subAccountId, java.lang.String name, java.lang.String cloudName, java.util.Map<java.lang.String,​java.lang.String> customAttributes, java.lang.Boolean enabled)  
    ApiResponse updateSubAccount​(java.lang.String subAccountId, java.lang.String name, java.lang.String cloudName, java.util.Map<java.lang.String,​java.lang.String> customAttributes, java.lang.Boolean enabled, java.util.Map<java.lang.String,​java.lang.Object> options)  
    ApiResponse updateUser​(java.lang.String userId, java.lang.String name, java.lang.String email, Account.Role role, java.lang.Boolean enabled, java.util.List<java.lang.String> subAccountsIds, java.util.Map<java.lang.String,​java.lang.Object> options)
    Update an existing user.
    ApiResponse updateUser​(java.lang.String userId, java.lang.String name, java.lang.String email, Account.Role role, java.util.List<java.lang.String> subAccountsIds)
    Update an existing user.
    ApiResponse updateUser​(java.lang.String userId, java.lang.String name, java.lang.String email, Account.Role role, java.util.List<java.lang.String> subAccountsIds, java.util.Map<java.lang.String,​java.lang.Object> options)
    Update an existing user.
    ApiResponse updateUserGroup​(java.lang.String groupId, java.lang.String name)
    Update an existing user group
    ApiResponse updateUserGroup​(java.lang.String groupId, java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> options)
    Update an existing user group
    ApiResponse user​(java.lang.String userId)
    Get details of a specific user.
    ApiResponse user​(java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Get details of a specific user.
    ApiResponse userGroup​(java.lang.String groupId)
    Get details of a group.
    ApiResponse userGroup​(java.lang.String groupId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Get details of a group.
    ApiResponse userGroups()
    Gets a list of all the user groups.
    ApiResponse userGroups​(java.util.Map<java.lang.String,​java.lang.Object> options)
    Gets a list of all the user groups.
    ApiResponse userGroupUsers​(java.lang.String groupId)
    Lists the users belonging to this user group.
    ApiResponse userGroupUsers​(java.lang.String groupId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Lists the users belonging to this user group.
    ApiResponse users​(java.lang.Boolean pending, java.util.List<java.lang.String> userIds, java.lang.String prefix, java.lang.String subAccountId)
    Get a list of the users according to filters.
    ApiResponse users​(java.lang.Boolean pending, java.util.List<java.lang.String> userIds, java.lang.String prefix, java.lang.String subAccountId, java.util.Map<java.lang.String,​java.lang.Object> options)
    Get a list of the users according to filters.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Account

      public Account​(Cloudinary cloudinary)
      Create a new instance to use the account API. The account information will be extracted from an environment variable CLOUDINARY_ACCOUNT_URL. If it's missing an exception will be thrown.
      Parameters:
      cloudinary - A cloudinary instance. This is used to fetch the correct network configuration.
    • Account

      public Account​(AccountConfiguration accountConfiguration, Cloudinary cloudinary)
      Create a new instance to use the account API. The account information will be extracted from
      Parameters:
      accountConfiguration - Account configuration to use in requests.
      cloudinary - A cloudinary instance. This is used to fetch the correct network configuration.
  • Method Details

    • subAccount

      public ApiResponse subAccount​(java.lang.String subAccountId) throws java.lang.Exception
      Get details of a specific sub account
      Parameters:
      subAccountId - The id of the sub account
      Returns:
      the sub account details.
      Throws:
      java.lang.Exception - If the request fails
    • subAccount

      public ApiResponse subAccount​(java.lang.String subAccountId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Get details of a specific sub account
      Parameters:
      subAccountId - The id of the sub account
      options - Generic advanced options map, see online documentation.
      Returns:
      the sub account details.
      Throws:
      java.lang.Exception - If the request fails
    • subAccounts

      public ApiResponse subAccounts​(java.lang.Boolean enabled, java.util.List<java.lang.String> ids, java.lang.String prefix) throws java.lang.Exception
      Get a list of sub accounts.
      Parameters:
      enabled - Optional. Whether to fetch enabled or disabled accounts. Default is all.
      ids - Optional. List of sub-account IDs. Up to 100. When provided, other filters are ignored.
      prefix - Optional. Search by prefix of the sub-account name. Case-insensitive.
      Returns:
      the list of sub-accounts details.
      Throws:
      java.lang.Exception - If the request fails
    • subAccounts

      public ApiResponse subAccounts​(java.lang.Boolean enabled, java.util.List<java.lang.String> ids, java.lang.String prefix, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Get a list of sub accounts.
      Parameters:
      enabled - Optional. Whether to fetch enabled or disabled accounts. Default is all.
      ids - Optional. List of sub-account IDs. Up to 100. When provided, other filters are ignored.
      prefix - Optional. Search by prefix of the sub-account name. Case-insensitive.
      options - Generic advanced options map, see online documentation.
      Returns:
      the list of sub-accounts details.
      Throws:
      java.lang.Exception - If the request fails
    • createSubAccount

      public ApiResponse createSubAccount​(java.lang.String name, java.lang.String cloudName, java.util.Map customAttributes, boolean enabled, java.lang.String baseAccount) throws java.lang.Exception
      Parameters:
      name - Required. The name displayed in the management console.
      cloudName - Optional, unique (case insensitive)
      customAttributes - Custom attributes associated with the sub-account, as a map of key/value pairs.
      enabled - Optional. Whether to create the account as enabled (default is enabled).
      baseAccount - Optional. ID of sub-account from which to copy settings
      Returns:
      details of the created sub-account
      Throws:
      java.lang.Exception - If the request fails
    • createSubAccount

      public ApiResponse createSubAccount​(java.lang.String name, java.lang.String cloudName, java.util.Map customAttributes, boolean enabled, java.lang.String baseAccount, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Parameters:
      name - Required. The name displayed in the management console.
      cloudName - Optional, unique (case insensitive)
      customAttributes - Custom attributes associated with the sub-account, as a map of key/value pairs.
      enabled - Optional. Whether to create the account as enabled (default is enabled).
      baseAccount - Optional. ID of sub-account from which to copy settings
      options - Generic advanced options map, see online documentation.
      Returns:
      details of the created sub-account
      Throws:
      java.lang.Exception - If the request fails
    • updateSubAccount

      public ApiResponse updateSubAccount​(java.lang.String subAccountId, java.lang.String name, java.lang.String cloudName, java.util.Map<java.lang.String,​java.lang.String> customAttributes, java.lang.Boolean enabled) throws java.lang.Exception
      Parameters:
      subAccountId - The id of the sub-account to update
      name - The name displayed in the management console.
      cloudName - The cloud name to set.
      customAttributes - ACustom attributes associated with the sub-account, as a map of key/value pairs.
      enabled - Set the sub-account as enabled or not.
      Returns:
      details of the updated sub-account
      Throws:
      java.lang.Exception - If the request fails
    • updateSubAccount

      public ApiResponse updateSubAccount​(java.lang.String subAccountId, java.lang.String name, java.lang.String cloudName, java.util.Map<java.lang.String,​java.lang.String> customAttributes, java.lang.Boolean enabled, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Parameters:
      subAccountId - The id of the sub-account to update
      name - The name displayed in the management console.
      cloudName - The cloud name to set.
      customAttributes - ACustom attributes associated with the sub-account, as a map of key/value pairs.
      enabled - Set the sub-account as enabled or not.
      options - Generic advanced options map, see online documentation.
      Returns:
      details of the updated sub-account
      Throws:
      java.lang.Exception - If the request fails
    • deleteSubAccount

      public ApiResponse deleteSubAccount​(java.lang.String subAccountId) throws java.lang.Exception
      Deletes the sub-account.
      Parameters:
      subAccountId - The id of the sub-account to delete
      Returns:
      result message.
      Throws:
      java.lang.Exception - If the request fails.
    • deleteSubAccount

      public ApiResponse deleteSubAccount​(java.lang.String subAccountId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Deletes the sub-account.
      Parameters:
      subAccountId - The id of the sub-account to delete
      options - Generic advanced options map, see online documentation.
      Returns:
      result message.
      Throws:
      java.lang.Exception - If the request fails.
    • user

      public ApiResponse user​(java.lang.String userId) throws java.lang.Exception
      Get details of a specific user.
      Parameters:
      userId - The id of the user to fetch
      Returns:
      details of the user.
      Throws:
      java.lang.Exception - If the request fails.
    • user

      public ApiResponse user​(java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Get details of a specific user.
      Parameters:
      userId - The id of the user to fetch
      options - Generic advanced options map, see online documentation.
      Returns:
      details of the user.
      Throws:
      java.lang.Exception - If the request fails.
    • users

      public ApiResponse users​(java.lang.Boolean pending, java.util.List<java.lang.String> userIds, java.lang.String prefix, java.lang.String subAccountId) throws java.lang.Exception
      Get a list of the users according to filters.
      Parameters:
      pending - Optional. Limit results to pending users (true), users that are not pending (false), or all users (null)
      userIds - Optionals. List of user IDs. Up to 100
      prefix - Optional. Search by prefix of the user's name or email. Case-insensitive
      subAccountId - Optional. Return only users who have access to the given sub-account
      Returns:
      the users' details.
      Throws:
      java.lang.Exception - If the request fails.
    • users

      public ApiResponse users​(java.lang.Boolean pending, java.util.List<java.lang.String> userIds, java.lang.String prefix, java.lang.String subAccountId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Get a list of the users according to filters.
      Parameters:
      pending - Optional. Limit results to pending users (true), users that are not pending (false), or all users (null)
      userIds - Optionals. List of user IDs. Up to 100
      prefix - Optional. Search by prefix of the user's name or email. Case-insensitive
      subAccountId - Optional. Return only users who have access to the given sub-account
      options - Generic advanced options map, see online documentation.
      Returns:
      the users' details.
      Throws:
      java.lang.Exception - If the request fails.
    • createUser

      public ApiResponse createUser​(java.lang.String name, java.lang.String email, Account.Role role, java.util.List<java.lang.String> subAccountsIds) throws java.lang.Exception
      Create a new user.
      Parameters:
      name - Required. Username.
      email - Required. User's email.
      role - Required. User's role.
      subAccountsIds - Optional. Sub-accounts for which the user should have access. If not provided or empty, user should have access to all accounts.
      Returns:
      The newly created user details.
      Throws:
      java.lang.Exception - If the request fails.
    • createUser

      public ApiResponse createUser​(java.lang.String name, java.lang.String email, Account.Role role, java.util.List<java.lang.String> subAccountsIds, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Create a new user.
      Parameters:
      name - Required. Username.
      email - Required. User's email.
      role - Required. User's role.
      subAccountsIds - Optional. Sub-accounts for which the user should have access. If not provided or empty, user should have access to all accounts.
      options - Generic advanced options map, see online documentation.
      Returns:
      The newly created user details.
      Throws:
      java.lang.Exception - If the request fails.
    • createUser

      public ApiResponse createUser​(java.lang.String name, java.lang.String email, Account.Role role, java.lang.Boolean enabled, java.util.List<java.lang.String> subAccountsIds, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Create a new user.
      Parameters:
      name - Required. Username.
      email - Required. User's email.
      role - Required. User's role.
      enabled - Optional. User's status (enabled or disabled).
      subAccountsIds - Optional. Sub-accounts for which the user should have access. If not provided or empty, user should have access to all accounts.
      options - Generic advanced options map, see online documentation.
      Returns:
      The newly created user details.
      Throws:
      java.lang.Exception - If the request fails.
    • updateUser

      public ApiResponse updateUser​(java.lang.String userId, java.lang.String name, java.lang.String email, Account.Role role, java.util.List<java.lang.String> subAccountsIds) throws java.lang.Exception
      Update an existing user.
      Parameters:
      userId - The id of the user to update.
      name - Username.
      email - User's email.
      role - User's role.
      subAccountsIds - Sub-accounts for which the user should have access. If not provided or empty, user should have access to all accounts.
      Returns:
      The updated user details
      Throws:
      java.lang.Exception - If the request fails.
    • updateUser

      public ApiResponse updateUser​(java.lang.String userId, java.lang.String name, java.lang.String email, Account.Role role, java.util.List<java.lang.String> subAccountsIds, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Update an existing user.
      Parameters:
      userId - The id of the user to update.
      name - Username.
      email - User's email.
      role - User's role.
      subAccountsIds - Sub-accounts for which the user should have access. If not provided or empty, user should have access to all accounts.
      options - Generic advanced options map, see online documentation.
      Returns:
      The updated user details
      Throws:
      java.lang.Exception - If the request fails.
    • updateUser

      public ApiResponse updateUser​(java.lang.String userId, java.lang.String name, java.lang.String email, Account.Role role, java.lang.Boolean enabled, java.util.List<java.lang.String> subAccountsIds, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Update an existing user.
      Parameters:
      userId - The id of the user to update.
      name - Username.
      email - User's email.
      role - User's role.
      enabled - User's status (enabled or disabled)
      subAccountsIds - Sub-accounts for which the user should have access. If not provided or empty, user should have access to all accounts.
      options - Generic advanced options map, see online documentation.
      Returns:
      The updated user details
      Throws:
      java.lang.Exception - If the request fails.
    • deleteUser

      public ApiResponse deleteUser​(java.lang.String userId) throws java.lang.Exception
      Delete a user.
      Parameters:
      userId - Id of the user to delete.
      Returns:
      result message.
      Throws:
      java.lang.Exception
    • deleteUser

      public ApiResponse deleteUser​(java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Delete a user.
      Parameters:
      userId - Id of the user to delete.
      options - Generic advanced options map, see online documentation.
      Returns:
      result message.
      Throws:
      java.lang.Exception
    • createUserGroup

      public ApiResponse createUserGroup​(java.lang.String name) throws java.lang.Exception
      Create a new user group
      Parameters:
      name - Required. Name for the group.
      Returns:
      The newly created group.
      Throws:
      java.lang.Exception - If the request fails
    • createUserGroup

      public ApiResponse createUserGroup​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Create a new user group
      Parameters:
      name - Required. Name for the group.
      options - Generic advanced options map, see online documentation.
      Returns:
      The newly created group.
      Throws:
      java.lang.Exception - If the request fails
    • updateUserGroup

      public ApiResponse updateUserGroup​(java.lang.String groupId, java.lang.String name) throws java.lang.Exception
      Update an existing user group
      Parameters:
      groupId - The id of the group to update
      name - The name of the group.
      Returns:
      The updated group.
      Throws:
      java.lang.Exception - If the request fails
    • updateUserGroup

      public ApiResponse updateUserGroup​(java.lang.String groupId, java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Update an existing user group
      Parameters:
      groupId - The id of the group to update
      name - The name of the group.
      options - Generic advanced options map, see online documentation.
      Returns:
      The updated group.
      Throws:
      java.lang.Exception - If the request fails
    • deleteUserGroup

      public ApiResponse deleteUserGroup​(java.lang.String groupId) throws java.lang.Exception
      Delete a user group
      Parameters:
      groupId - The group id to delete
      Returns:
      A result message.
      Throws:
      java.lang.Exception - if the request fails.
    • deleteUserGroup

      public ApiResponse deleteUserGroup​(java.lang.String groupId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Delete a user group
      Parameters:
      groupId - The group id to delete
      options - Generic advanced options map, see online documentation.
      Returns:
      A result message.
      Throws:
      java.lang.Exception - if the request fails.
    • addUserToGroup

      public ApiResponse addUserToGroup​(java.lang.String groupId, java.lang.String userId) throws java.lang.Exception
      Add an existing user to a group.
      Parameters:
      groupId - The group id.
      userId - The user id to add.
      Throws:
      java.lang.Exception - If the request fails
    • addUserToGroup

      public ApiResponse addUserToGroup​(java.lang.String groupId, java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Add an existing user to a group.
      Parameters:
      groupId - The group id.
      userId - The user id to add.
      options - Generic advanced options map, see online documentation.
      Throws:
      java.lang.Exception - If the request fails
    • removeUserFromGroup

      public ApiResponse removeUserFromGroup​(java.lang.String groupId, java.lang.String userId) throws java.lang.Exception
      Removes a user from a group.
      Parameters:
      groupId - The group id.
      userId - The id of the user to remove
      Returns:
      A result message
      Throws:
      java.lang.Exception - If the request fails.
    • removeUserFromGroup

      public ApiResponse removeUserFromGroup​(java.lang.String groupId, java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Removes a user from a group.
      Parameters:
      groupId - The group id.
      userId - The id of the user to remove
      options - Generic advanced options map, see online documentation.
      Returns:
      A result message
      Throws:
      java.lang.Exception - If the request fails.
    • userGroup

      public ApiResponse userGroup​(java.lang.String groupId) throws java.lang.Exception
      Get details of a group.
      Parameters:
      groupId - The group id to fetch
      Returns:
      Details of the group.
      Throws:
      java.lang.Exception - If the request fails.
    • userGroup

      public ApiResponse userGroup​(java.lang.String groupId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Get details of a group.
      Parameters:
      groupId - The group id to fetch
      options - Generic advanced options map, see online documentation.
      Returns:
      Details of the group.
      Throws:
      java.lang.Exception - If the request fails.
    • userGroups

      public ApiResponse userGroups() throws java.lang.Exception
      Gets a list of all the user groups.
      Returns:
      The list of the groups.
      Throws:
      java.lang.Exception - If the request fails.
    • userGroups

      public ApiResponse userGroups​(java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Gets a list of all the user groups.
      Parameters:
      options - Generic advanced options map, see online documentation.
      Returns:
      The list of the groups.
      Throws:
      java.lang.Exception - If the request fails.
    • userGroupUsers

      public ApiResponse userGroupUsers​(java.lang.String groupId) throws java.lang.Exception
      Lists the users belonging to this user group.
      Parameters:
      groupId - The id of the user group.
      Returns:
      The list of users in that group.
      Throws:
      java.lang.Exception - If the request fails.
    • userGroupUsers

      public ApiResponse userGroupUsers​(java.lang.String groupId, java.util.Map<java.lang.String,​java.lang.Object> options) throws java.lang.Exception
      Lists the users belonging to this user group.
      Parameters:
      groupId - The id of the user group.
      options - Generic advanced options map, see online documentation.
      Returns:
      The list of users in that group.
      Throws:
      java.lang.Exception - If the request fails.