Interface UserApi


  • public interface UserApi
    This API is for creating, listing, and deleting a User. Also allows listing, granting, and revoking access permissions for users.
    See Also:
    User
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void create​(String userName, String password, String databaseName)
      Create a database user by name, password, and database name.
      void create​(String userName, String password, String host, String databaseName)
      Create a database user by name, password, and database name.
      void create​(Set<User> users)
      Create database users.
      boolean delete​(String userName)
      This operation deletes the specified user for the specified database instance.
      User get​(String name)
      Returns a User by identifier.
      User get​(String name, String hostname)
      Returns a User by name and allowed host.
      com.google.common.collect.FluentIterable<String> getDatabaseList​(String userName)
      This operation shows a list of all databases to which a user has access.
      void grant​(String userName, String databaseName)
      This operation grants access for the specified user to a database for the specified instance.
      void grant​(String userName, List<String> databases)
      This operation grants access for the specified user to a database for the specified instance.
      com.google.common.collect.FluentIterable<User> list()
      This operation lists the users in the specified database instance.
      boolean revoke​(String userName, String databaseName)
      This operation grants access for the specified user to a database for the specified instance.
    • Method Detail

      • create

        @Named("user:create")
        @POST
        @Path("/users")
        @Consumes("application/json")
        void create​(Set<User> users)
        Create database users. A user is granted all privileges on the specified databases. The following user name is reserved and cannot be used for creating users: root. This method can be used to create users with access restrictions by host
        Parameters:
        users - List of users to be created.
        See Also:
        User Access Restriction by Host
      • create

        @Named("user:create")
        @POST
        @Path("/users")
        @Consumes("application/json")
        void create​(String userName,
                    String password,
                    String databaseName)
        Create a database user by name, password, and database name. Simpler overload for #create(String, Set).
        Parameters:
        userName - Name of the user for the database.
        password - User password for database access.
        databaseName - Name of the database that the user can access.
      • create

        @Named("user:create")
        @POST
        @Path("/users")
        @Consumes("application/json")
        void create​(String userName,
                    String password,
                    String host,
                    String databaseName)
        Create a database user by name, password, and database name. Simpler overload for #create(String, Set).
        Parameters:
        userName - Name of the user for the database.
        password - User password for database access.
        host - Specifies the host from which a user is allowed to connect to the database. Possible values are a string containing an IPv4 address or "%" to allow connecting from any host. Refer to Section 3.11.1, “User Access Restriction by Host” for details. If host is not specified, it defaults to "%".
        databaseName - Name of the database that the user can access.
      • grant

        @Named("user:grant")
        @PUT
        @Path("/users/{name}/databases")
        @Consumes("application/json")
        void grant​(@PathParam("name")
                   String userName,
                   List<String> databases)
        This operation grants access for the specified user to a database for the specified instance. The user is granted all privileges.
        Parameters:
        userName - The name of the specified user.
        databases - List of the databases that the user should be granted access to.
      • grant

        @Named("user:grant")
        @PUT
        @Path("/users/{name}/databases")
        @Consumes("application/json")
        void grant​(@PathParam("name")
                   String userName,
                   String databaseName)
        This operation grants access for the specified user to a database for the specified instance. Simpler overload for #create(String, Set). The user is granted all privileges.
        Parameters:
        userName - Name of the user for the database.
        databaseName - Name of the database that the user can access.
      • revoke

        @Named("user:revoke")
        @DELETE
        @Path("/users/{name}/databases/{databaseName}")
        @Consumes("application/json")
        boolean revoke​(@PathParam("name")
                       String userName,
                       @PathParam("databaseName")
                       String databaseName)
        This operation grants access for the specified user to a database for the specified instance. The user is granted all privileges.
        Parameters:
        userName - Name of the user for the database.
        databaseName - Name of the database that the user can access.
        Returns:
        true if successful.
      • delete

        @Named("users:delete/{name}")
        @DELETE
        @Path("/users/{name}")
        @Consumes("application/json")
        boolean delete​(@PathParam("name")
                       String userName)
        This operation deletes the specified user for the specified database instance.
        Parameters:
        userName - The name for the specified user.
        Returns:
        true if successful.
      • list

        @Named("user:list")
        @GET
        @Path("/users")
        @Consumes("application/json")
        com.google.common.collect.FluentIterable<User> list()
        This operation lists the users in the specified database instance. This operation does not return the system users (database administrators that administer the health of the database). Also, this operation returns the "root" user only if "root" user has been enabled.
        Returns:
        The list of Users.
      • getDatabaseList

        @Named("user:getDatabaseList/{name}")
        @GET
        @Path("/users/{name}/databases")
        @Consumes("application/json")
        com.google.common.collect.FluentIterable<String> getDatabaseList​(@PathParam("name")
                                                                         String userName)
        This operation shows a list of all databases to which a user has access.
        Parameters:
        instanceId - The instance ID for the specified database instance.
        userName - The name for the specified user.
        Returns:
        The list of Users.
      • get

        @Named("user:get/{name}")
        @GET
        @Path("/users/{name}")
        @Consumes("application/json")
        @Nullable
        User get​(@PathParam("name")
                 String name)
        Returns a User by identifier.
        Parameters:
        name - The name or identifier for the specified user.
        Returns:
        User or Null on not found.
      • get

        @Named("user:get/{name}@{hostname}")
        @GET
        @Path("/users/{name}@{hostname}")
        @Consumes("application/json")
        @Nullable
        User get​(@PathParam("name")
                 String name,
                 @PathParam("hostname")
                 String hostname)
        Returns a User by name and allowed host.
        Parameters:
        name - The name for the specified user.
        host - The associated hostname.
        Returns:
        User or Null on not found.