public class GravitinoClient extends GravitinoClientBase implements SupportsCatalogs, TagOperations
It uses an underlying RESTClient to send HTTP requests and receive responses from the
API.
| Modifier and Type | Class and Description |
|---|---|
static class |
GravitinoClient.ClientBuilder
Builder class for constructing a GravitinoClient.
|
GravitinoClientBase.Builder<T>API_METALAKES_IDENTIFIER_PATH, API_METALAKES_LIST_PATH, restClient| Modifier and Type | Method and Description |
|---|---|
Group |
addGroup(java.lang.String group)
Adds a new Group.
|
User |
addUser(java.lang.String user)
Adds a new User.
|
Catalog |
alterCatalog(java.lang.String catalogName,
CatalogChange... changes)
Alter a catalog with specified identifier.
|
Tag |
alterTag(java.lang.String name,
TagChange... changes)
Alter a tag under a metalake.
|
static GravitinoClient.ClientBuilder |
builder(java.lang.String uri)
Creates a new builder for constructing a GravitinoClient.
|
Catalog |
createCatalog(java.lang.String catalogName,
Catalog.Type type,
java.lang.String provider,
java.lang.String comment,
java.util.Map<java.lang.String,java.lang.String> properties)
Create a catalog with specified identifier.
|
Role |
createRole(java.lang.String role,
java.util.Map<java.lang.String,java.lang.String> properties,
java.util.List<SecurableObject> securableObjects)
Creates a new Role.
|
Tag |
createTag(java.lang.String name,
java.lang.String comment,
java.util.Map<java.lang.String,java.lang.String> properties)
Create a tag under a metalake.
|
boolean |
deleteRole(java.lang.String role)
Deletes a Role.
|
boolean |
deleteTag(java.lang.String name)
Delete a tag under a metalake.
|
boolean |
dropCatalog(java.lang.String catalogName)
Drop a catalog with specified identifier.
|
Group |
getGroup(java.lang.String group)
Gets a Group.
|
java.util.Optional<Owner> |
getOwner(MetadataObject object)
Get the owner of a metadata object.
|
Role |
getRole(java.lang.String role)
Gets a Role.
|
Tag |
getTag(java.lang.String name)
Get a tag by its name under a metalake.
|
User |
getUser(java.lang.String user)
Gets a User.
|
Role |
grantPrivilegesToRole(java.lang.String role,
MetadataObject object,
java.util.List<Privilege> privileges)
Grant privileges to a role.
|
Group |
grantRolesToGroup(java.util.List<java.lang.String> roles,
java.lang.String group)
Grant roles to a group.
|
User |
grantRolesToUser(java.util.List<java.lang.String> roles,
java.lang.String user)
Grant roles to a user.
|
java.lang.String[] |
listCatalogs()
List the name of all catalogs in the metalake.
|
Catalog[] |
listCatalogsInfo()
List all catalogs with their information in the metalake.
|
java.lang.String[] |
listGroupNames()
List the group names.
|
Group[] |
listGroups()
List the groups.
|
java.lang.String[] |
listRoleNames()
Lists the role names.
|
java.lang.String[] |
listTags()
List all the tag names under a metalake.
|
Tag[] |
listTagsInfo()
List all the tags with detailed information under a metalake.
|
java.lang.String[] |
listUserNames()
Lists the usernames.
|
User[] |
listUsers()
Lists the users.
|
Catalog |
loadCatalog(java.lang.String catalogName)
Load a catalog by its identifier.
|
boolean |
removeGroup(java.lang.String group)
Removes a Group.
|
boolean |
removeUser(java.lang.String user)
Removes a User.
|
Role |
revokePrivilegesFromRole(java.lang.String role,
MetadataObject object,
java.util.List<Privilege> privileges)
Revoke privileges from a role.
|
Group |
revokeRolesFromGroup(java.util.List<java.lang.String> roles,
java.lang.String group)
Revoke roles from a group.
|
User |
revokeRolesFromUser(java.util.List<java.lang.String> roles,
java.lang.String user)
Revoke roles from a user.
|
void |
setOwner(MetadataObject object,
java.lang.String ownerName,
Owner.Type ownerType)
Set the owner of a metadata object.
|
void |
testConnection(java.lang.String catalogName,
Catalog.Type type,
java.lang.String provider,
java.lang.String comment,
java.util.Map<java.lang.String,java.lang.String> properties)
Test whether a catalog can be created successfully with the specified parameters, without
actually creating it.
|
checkMetalakeName, checkVersion, clientVersion, close, getVersion, loadMetalake, serverVersionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcatalogExistspublic java.lang.String[] listCatalogs()
throws NoSuchMetalakeException
SupportsCatalogslistCatalogs in interface SupportsCatalogsNoSuchMetalakeException - If the metalake does not exist.public Catalog[] listCatalogsInfo() throws NoSuchMetalakeException
SupportsCatalogslistCatalogsInfo in interface SupportsCatalogsNoSuchMetalakeException - If the metalake with namespace does not exist.public Catalog loadCatalog(java.lang.String catalogName) throws NoSuchCatalogException
SupportsCatalogsloadCatalog in interface SupportsCatalogscatalogName - the identifier of the catalog.NoSuchCatalogException - If the catalog does not exist.public Catalog createCatalog(java.lang.String catalogName, Catalog.Type type, java.lang.String provider, java.lang.String comment, java.util.Map<java.lang.String,java.lang.String> properties) throws NoSuchMetalakeException, CatalogAlreadyExistsException
SupportsCatalogsThe parameter "provider" is a short name of the catalog, used to tell Gravitino which
catalog should be created. The short name should be the same as the CatalogProvider
interface provided.
createCatalog in interface SupportsCatalogscatalogName - the name of the catalog.type - the type of the catalog.provider - the provider of the catalog.comment - the comment of the catalog.properties - the properties of the catalog.NoSuchMetalakeException - If the metalake does not exist.CatalogAlreadyExistsException - If the catalog already exists.public Catalog alterCatalog(java.lang.String catalogName, CatalogChange... changes) throws NoSuchCatalogException, java.lang.IllegalArgumentException
SupportsCatalogsalterCatalog in interface SupportsCatalogscatalogName - the identifier of the catalog.changes - the changes to apply to the catalog.NoSuchCatalogException - If the catalog does not exist.java.lang.IllegalArgumentException - If the changes cannot be applied to the catalog.public boolean dropCatalog(java.lang.String catalogName)
SupportsCatalogsdropCatalog in interface SupportsCatalogscatalogName - the name of the catalog.public User addUser(java.lang.String user) throws UserAlreadyExistsException, NoSuchMetalakeException
user - The name of the User.UserAlreadyExistsException - If a User with the same name already exists.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If adding the User encounters storage issues.public boolean removeUser(java.lang.String user)
throws NoSuchMetalakeException
user - The name of the User.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If removing the User encounters storage issues.public User getUser(java.lang.String user) throws NoSuchUserException, NoSuchMetalakeException
user - The name of the User.NoSuchUserException - If the User with the given name does not exist.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If getting the User encounters storage issues.public User[] listUsers()
NoSuchMetalakeException - If the Metalake with the given name does not exist.public java.lang.String[] listUserNames()
NoSuchMetalakeException - If the Metalake with the given name does not exist.public Group addGroup(java.lang.String group) throws GroupAlreadyExistsException, NoSuchMetalakeException
group - The name of the Group.GroupAlreadyExistsException - If a Group with the same name already exists.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If adding the Group encounters storage issues.public boolean removeGroup(java.lang.String group)
throws NoSuchMetalakeException
group - THe name of the Group.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If removing the Group encounters storage issues.public Group getGroup(java.lang.String group) throws NoSuchGroupException, NoSuchMetalakeException
group - The name of the Group.NoSuchGroupException - If the Group with the given name does not exist.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If getting the Group encounters storage issues.public Group[] listGroups() throws NoSuchMetalakeException
NoSuchMetalakeException - If the Metalake with the given name does not exist.public java.lang.String[] listGroupNames()
throws NoSuchMetalakeException
NoSuchMetalakeException - If the Metalake with the given name does not exist.public Role getRole(java.lang.String role) throws NoSuchRoleException, NoSuchMetalakeException
role - The name of the Role.NoSuchRoleException - If the Role with the given name does not exist.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If getting the Role encounters storage issues.public boolean deleteRole(java.lang.String role)
throws NoSuchMetalakeException
role - The name of the Role.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If deleting the Role encounters storage issues.public Role createRole(java.lang.String role, java.util.Map<java.lang.String,java.lang.String> properties, java.util.List<SecurableObject> securableObjects) throws RoleAlreadyExistsException, NoSuchMetalakeException, NoSuchMetadataObjectException
role - The name of the Role.properties - The properties of the Role.securableObjects - The securable objects of the Role.RoleAlreadyExistsException - If a Role with the same name already exists.NoSuchMetalakeException - If the Metalake with the given name does not exist.NoSuchMetadataObjectException - If securable object doesn't existjava.lang.RuntimeException - If creating the Role encounters storage issues.public User grantRolesToUser(java.util.List<java.lang.String> roles, java.lang.String user) throws NoSuchUserException, NoSuchRoleException, NoSuchMetalakeException
user - The name of the User.roles - The names of the Role.NoSuchUserException - If the User with the given name does not exist.NoSuchRoleException - If the Role with the given name does not exist.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If granting roles to a user encounters storage issues.public Group grantRolesToGroup(java.util.List<java.lang.String> roles, java.lang.String group) throws NoSuchGroupException, NoSuchRoleException, NoSuchMetalakeException
group - The name of the Group.roles - The names of the Role.NoSuchGroupException - If the Group with the given name does not exist.NoSuchRoleException - If the Role with the given name does not exist.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If granting roles to a group encounters storage issues.public User revokeRolesFromUser(java.util.List<java.lang.String> roles, java.lang.String user) throws NoSuchUserException, NoSuchRoleException, NoSuchMetalakeException
user - The name of the User.roles - The names of the Role.NoSuchUserException - If the User with the given name does not exist.NoSuchRoleException - If the Role with the given name does not exist.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If revoking roles from a user encounters storage issues.public Group revokeRolesFromGroup(java.util.List<java.lang.String> roles, java.lang.String group) throws NoSuchGroupException, NoSuchRoleException, NoSuchMetalakeException
group - The name of the Group.roles - The names of the Role.NoSuchGroupException - If the Group with the given name does not exist.NoSuchRoleException - If the Role with the given name does not exist.NoSuchMetalakeException - If the Metalake with the given name does not exist.java.lang.RuntimeException - If revoking roles from a group encounters storage issues.public java.util.Optional<Owner> getOwner(MetadataObject object) throws NoSuchMetadataObjectException
object - The metadata objectNoSuchMetadataObjectException - If the metadata object is not found.public void setOwner(MetadataObject object, java.lang.String ownerName, Owner.Type ownerType) throws NotFoundException
object - The metadata object.ownerName - The name of the ownerownerType - The type of the owner, The owner can be a user or a group.NotFoundException - If the metadata object isn't found or the owner doesn't exist.public java.lang.String[] listRoleNames()
throws NoSuchMetalakeException
NoSuchMetalakeException - If the Metalake with the given name does not exist.public Role grantPrivilegesToRole(java.lang.String role, MetadataObject object, java.util.List<Privilege> privileges) throws NoSuchRoleException, NoSuchMetadataObjectException, NoSuchMetalakeException, IllegalPrivilegeException
role - The name of the role.privileges - The privileges to grant.object - The object is associated with privileges to grant.NoSuchRoleException - If the role with the given name does not exist.NoSuchMetadataObjectException - If the metadata object with the given name does not
exist.NoSuchMetalakeException - If the Metalake with the given name does not exist.IllegalPrivilegeException - If any privilege can't be bind to the metadata object.java.lang.RuntimeException - If granting roles to a role encounters storage issues.public Role revokePrivilegesFromRole(java.lang.String role, MetadataObject object, java.util.List<Privilege> privileges) throws NoSuchRoleException, NoSuchMetadataObjectException, NoSuchMetalakeException, IllegalPrivilegeException
role - The name of the role.privileges - The privileges to revoke.object - The object is associated with privileges to revoke.NoSuchRoleException - If the role with the given name does not exist.NoSuchMetadataObjectException - If the metadata object with the given name does not
exist.NoSuchMetalakeException - If the Metalake with the given name does not exist.IllegalPrivilegeException - If any privilege can't be bind to the metadata object.java.lang.RuntimeException - If revoking privileges from a role encounters storage issues.public static GravitinoClient.ClientBuilder builder(java.lang.String uri)
uri - The base URI for the Gravitino API.public void testConnection(java.lang.String catalogName,
Catalog.Type type,
java.lang.String provider,
java.lang.String comment,
java.util.Map<java.lang.String,java.lang.String> properties)
throws java.lang.Exception
testConnection in interface SupportsCatalogscatalogName - the name of the catalog.type - the type of the catalog.provider - the provider of the catalog.comment - the comment of the catalog.properties - the properties of the catalog.java.lang.Exception - if the test failed.public java.lang.String[] listTags()
throws NoSuchMetalakeException
TagOperationslistTags in interface TagOperationsNoSuchMetalakeException - If the metalake does not exist.public Tag[] listTagsInfo() throws NoSuchMetalakeException
TagOperationslistTagsInfo in interface TagOperationsNoSuchMetalakeException - If the metalake does not exist.public Tag getTag(java.lang.String name) throws NoSuchTagException
TagOperationsgetTag in interface TagOperationsname - The name of the tag.NoSuchTagException - If the tag does not exist.public Tag createTag(java.lang.String name, java.lang.String comment, java.util.Map<java.lang.String,java.lang.String> properties) throws TagAlreadyExistsException
TagOperationscreateTag in interface TagOperationsname - The name of the tag.comment - The comment of the tag.properties - The properties of the tag.TagAlreadyExistsException - If the tag already exists.public Tag alterTag(java.lang.String name, TagChange... changes) throws NoSuchTagException, java.lang.IllegalArgumentException
TagOperationsalterTag in interface TagOperationsname - The name of the tag.changes - The changes to apply to the tag.NoSuchTagException - If the tag does not exist.java.lang.IllegalArgumentException - If the changes cannot be applied to the tag.public boolean deleteTag(java.lang.String name)
TagOperationsdeleteTag in interface TagOperationsname - The name of the tag.