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.
|
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[] |
listTags()
List all the tag names under a metalake.
|
Tag[] |
listTagsInfo()
List all the tags with detailed information under a metalake.
|
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.
|
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, serverVersion
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
catalogExists
public java.lang.String[] listCatalogs() throws NoSuchMetalakeException
SupportsCatalogs
listCatalogs
in interface SupportsCatalogs
NoSuchMetalakeException
- If the metalake does not exist.public Catalog[] listCatalogsInfo() throws NoSuchMetalakeException
SupportsCatalogs
listCatalogsInfo
in interface SupportsCatalogs
NoSuchMetalakeException
- If the metalake with namespace does not exist.public Catalog loadCatalog(java.lang.String catalogName) throws NoSuchCatalogException
SupportsCatalogs
loadCatalog
in interface SupportsCatalogs
catalogName
- 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
SupportsCatalogs
The 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 SupportsCatalogs
catalogName
- 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
SupportsCatalogs
alterCatalog
in interface SupportsCatalogs
catalogName
- 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)
SupportsCatalogs
dropCatalog
in interface SupportsCatalogs
catalogName
- 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 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 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 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 SupportsCatalogs
catalogName
- 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
TagOperations
listTags
in interface TagOperations
NoSuchMetalakeException
- If the metalake does not exist.public Tag[] listTagsInfo() throws NoSuchMetalakeException
TagOperations
listTagsInfo
in interface TagOperations
NoSuchMetalakeException
- If the metalake does not exist.public Tag getTag(java.lang.String name) throws NoSuchTagException
TagOperations
getTag
in interface TagOperations
name
- 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
TagOperations
createTag
in interface TagOperations
name
- 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
TagOperations
alterTag
in interface TagOperations
name
- 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)
TagOperations
deleteTag
in interface TagOperations
name
- The name of the tag.