com.arangodb.ArangoDatabase Maven / Gradle / Ivy
/*
* DISCLAIMER
*
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright holder is ArangoDB GmbH, Cologne, Germany
*/
package com.arangodb;
import java.util.Collection;
import java.util.Map;
import com.arangodb.entity.AqlExecutionExplainEntity;
import com.arangodb.entity.AqlFunctionEntity;
import com.arangodb.entity.AqlParseEntity;
import com.arangodb.entity.ArangoDBVersion;
import com.arangodb.entity.CollectionEntity;
import com.arangodb.entity.DatabaseEntity;
import com.arangodb.entity.EdgeDefinition;
import com.arangodb.entity.GraphEntity;
import com.arangodb.entity.IndexEntity;
import com.arangodb.entity.Permissions;
import com.arangodb.entity.QueryCachePropertiesEntity;
import com.arangodb.entity.QueryEntity;
import com.arangodb.entity.QueryTrackingPropertiesEntity;
import com.arangodb.entity.TraversalEntity;
import com.arangodb.model.AqlFunctionCreateOptions;
import com.arangodb.model.AqlFunctionDeleteOptions;
import com.arangodb.model.AqlFunctionGetOptions;
import com.arangodb.model.AqlQueryExplainOptions;
import com.arangodb.model.AqlQueryOptions;
import com.arangodb.model.CollectionCreateOptions;
import com.arangodb.model.CollectionsReadOptions;
import com.arangodb.model.DocumentReadOptions;
import com.arangodb.model.GraphCreateOptions;
import com.arangodb.model.TransactionOptions;
import com.arangodb.model.TraversalOptions;
/**
* @author Mark Vollmary
*
*/
public interface ArangoDatabase {
/**
* Return the main entry point for the ArangoDB driver
*
* @return main entry point
*/
ArangoDB arango();
/**
* Returns the name of the database
*
* @return database name
*/
String name();
/**
* Returns the server name and version number.
*
* @see API
* Documentation
* @return the server version, number
* @throws ArangoDBException
*/
ArangoDBVersion getVersion() throws ArangoDBException;
/**
* Checks whether the database exists
*
* @return true if the database exists, otherwise false
*/
boolean exists() throws ArangoDBException;
/**
* Retrieves a list of all databases the current user can access
*
* @see API
* Documentation
* @return a list of all databases the current user can access
* @throws ArangoDBException
*/
Collection getAccessibleDatabases() throws ArangoDBException;
/**
* Returns a handler of the collection by the given name
*
* @param name
* Name of the collection
* @return collection handler
*/
ArangoCollection collection(final String name);
/**
* Creates a collection
*
* @see API
* Documentation
* @param name
* The name of the collection
* @return information about the collection
* @throws ArangoDBException
*/
CollectionEntity createCollection(final String name) throws ArangoDBException;
/**
* Creates a collection
*
* @see API
* Documentation
* @param name
* The name of the collection
* @param options
* Additional options, can be null
* @return information about the collection
* @throws ArangoDBException
*/
CollectionEntity createCollection(final String name, final CollectionCreateOptions options)
throws ArangoDBException;
/**
* Returns all collections
*
* @see API
* Documentation
* @return list of information about all collections
* @throws ArangoDBException
*/
Collection getCollections() throws ArangoDBException;
/**
* Returns all collections
*
* @see API
* Documentation
* @param options
* Additional options, can be null
* @return list of information about all collections
* @throws ArangoDBException
*/
Collection getCollections(final CollectionsReadOptions options) throws ArangoDBException;
/**
* Returns an index
*
* @see API Documentation
* @param id
* The index-handle
* @return information about the index
* @throws ArangoDBException
*/
IndexEntity getIndex(final String id) throws ArangoDBException;
/**
* Deletes an index
*
* @see API Documentation
* @param id
* The index-handle
* @return the id of the index
* @throws ArangoDBException
*/
String deleteIndex(final String id) throws ArangoDBException;
/**
* Creates the database
*
* @see API
* Documentation
* @return true if the database was created successfully.
* @throws ArangoDBException
*/
Boolean create() throws ArangoDBException;
/**
* Drop an existing database
*
* @see API
* Documentation
* @return true if the database was dropped successfully
* @throws ArangoDBException
*/
Boolean drop() throws ArangoDBException;
/**
* Grants or revoke access to the database for user user
. You need permission to the _system database
* in order to execute this call.
*
* @see
* API Documentation
* @param user
* The name of the user
* @param permissions
* The permissions the user grant
* @throws ArangoDBException
*/
void grantAccess(final String user, final Permissions permissions) throws ArangoDBException;
/**
* Grants access to the database for user user
. You need permission to the _system database in order to
* execute this call.
*
* @see
* API Documentation
* @param user
* The name of the user
* @throws ArangoDBException
*/
void grantAccess(final String user) throws ArangoDBException;
/**
* Revokes access to the database dbname for user user
. You need permission to the _system database in
* order to execute this call.
*
* @see
* API Documentation
* @param user
* The name of the user
* @throws ArangoDBException
*/
void revokeAccess(final String user) throws ArangoDBException;
/**
* Clear the database access level, revert back to the default access level.
*
* @see
* API Documentation
* @param user
* The name of the user
* @since ArangoDB 3.2.0
* @throws ArangoDBException
*/
void resetAccess(final String user) throws ArangoDBException;
/**
* Sets the default access level for collections within this database for the user user
. You need
* permission to the _system database in order to execute this call.
*
* @param user
* The name of the user
* @param permissions
* The permissions the user grant
* @since ArangoDB 3.2.0
* @throws ArangoDBException
*/
void grantDefaultCollectionAccess(final String user, final Permissions permissions) throws ArangoDBException;
/**
* Get specific database access level
*
* @see API
* Documentation
* @param user
* The name of the user
* @return permissions of the user
* @since ArangoDB 3.2.0
* @throws ArangoDBException
*/
Permissions getPermissions(final String user) throws ArangoDBException;
/**
* Create a cursor and return the first results
*
* @see API
* Documentation
* @param query
* contains the query string to be executed
* @param bindVars
* key/value pairs representing the bind parameters
* @param options
* Additional options, can be null
* @param type
* The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
* @return cursor of the results
* @throws ArangoDBException
*/
ArangoCursor query(
final String query,
final Map bindVars,
final AqlQueryOptions options,
final Class type) throws ArangoDBException;
/**
* Return an cursor from the given cursor-ID if still existing
*
* @see API
* Documentation
* @param cursorId
* The ID of the cursor
* @param type
* The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
* @return cursor of the results
* @throws ArangoDBException
*/
ArangoCursor cursor(final String cursorId, final Class type) throws ArangoDBException;
/**
* Explain an AQL query and return information about it
*
* @see API
* Documentation
* @param query
* the query which you want explained
* @param bindVars
* key/value pairs representing the bind parameters
* @param options
* Additional options, can be null
* @return information about the query
* @throws ArangoDBException
*/
AqlExecutionExplainEntity explainQuery(
final String query,
final Map bindVars,
final AqlQueryExplainOptions options) throws ArangoDBException;
/**
* Parse an AQL query and return information about it This method is for query validation only. To actually query
* the database, see {@link ArangoDatabase#query(String, Map, AqlQueryOptions, Class)}
*
* @see API
* Documentation
* @param query
* the query which you want parse
* @return imformation about the query
* @throws ArangoDBException
*/
AqlParseEntity parseQuery(final String query) throws ArangoDBException;
/**
* Clears the AQL query cache
*
* @see API
* Documentation
* @throws ArangoDBException
*/
void clearQueryCache() throws ArangoDBException;
/**
* Returns the global configuration for the AQL query cache
*
* @see API
* Documentation
* @return configuration for the AQL query cache
* @throws ArangoDBException
*/
QueryCachePropertiesEntity getQueryCacheProperties() throws ArangoDBException;
/**
* Changes the configuration for the AQL query cache. Note: changing the properties may invalidate all results in
* the cache.
*
* @see API
* Documentation
* @param properties
* properties to be set
* @return current set of properties
* @throws ArangoDBException
*/
QueryCachePropertiesEntity setQueryCacheProperties(final QueryCachePropertiesEntity properties)
throws ArangoDBException;
/**
* Returns the configuration for the AQL query tracking
*
* @see API
* Documentation
* @return configuration for the AQL query tracking
* @throws ArangoDBException
*/
QueryTrackingPropertiesEntity getQueryTrackingProperties() throws ArangoDBException;
/**
* Changes the configuration for the AQL query tracking
*
* @see API
* Documentation
* @param properties
* properties to be set
* @return current set of properties
* @throws ArangoDBException
*/
QueryTrackingPropertiesEntity setQueryTrackingProperties(final QueryTrackingPropertiesEntity properties)
throws ArangoDBException;
/**
* Returns a list of currently running AQL queries
*
* @see API
* Documentation
* @return a list of currently running AQL queries
* @throws ArangoDBException
*/
Collection getCurrentlyRunningQueries() throws ArangoDBException;
/**
* Returns a list of slow running AQL queries
*
* @see API
* Documentation
* @return a list of slow running AQL queries
* @throws ArangoDBException
*/
Collection getSlowQueries() throws ArangoDBException;
/**
* Clears the list of slow AQL queries
*
* @see API
* Documentation
* @throws ArangoDBException
*/
void clearSlowQueries() throws ArangoDBException;
/**
* Kills a running query. The query will be terminated at the next cancelation point.
*
* @see API
* Documentation
* @param id
* The id of the query
* @throws ArangoDBException
*/
void killQuery(final String id) throws ArangoDBException;
/**
* Create a new AQL user function
*
* @see API
* Documentation
* @param name
* the fully qualified name of the user functions
* @param code
* a string representation of the function body
* @param options
* Additional options, can be null
* @throws ArangoDBException
*/
void createAqlFunction(final String name, final String code, final AqlFunctionCreateOptions options)
throws ArangoDBException;
/**
* Remove an existing AQL user function
*
* @see API
* Documentation
* @param name
* the name of the AQL user function
* @param options
* Additional options, can be null
* @return number of deleted functions (since ArangoDB 3.4.0)
* @throws ArangoDBException
*/
Integer deleteAqlFunction(final String name, final AqlFunctionDeleteOptions options) throws ArangoDBException;
/**
* Gets all reqistered AQL user functions
*
* @see API
* Documentation
* @param options
* Additional options, can be null
* @return all reqistered AQL user functions
* @throws ArangoDBException
*/
Collection getAqlFunctions(final AqlFunctionGetOptions options) throws ArangoDBException;
/**
* Returns a handler of the graph by the given name
*
* @param name
* Name of the graph
* @return graph handler
*/
ArangoGraph graph(final String name);
/**
* Create a new graph in the graph module. The creation of a graph requires the name of the graph and a definition
* of its edges.
*
* @see API
* Documentation
* @param name
* Name of the graph
* @param edgeDefinitions
* An array of definitions for the edge
* @return information about the graph
* @throws ArangoDBException
*/
GraphEntity createGraph(final String name, final Collection edgeDefinitions)
throws ArangoDBException;
/**
* Create a new graph in the graph module. The creation of a graph requires the name of the graph and a definition
* of its edges.
*
* @see API
* Documentation
* @param name
* Name of the graph
* @param edgeDefinitions
* An array of definitions for the edge
* @param options
* Additional options, can be null
* @return information about the graph
* @throws ArangoDBException
*/
GraphEntity createGraph(
final String name,
final Collection edgeDefinitions,
final GraphCreateOptions options) throws ArangoDBException;
/**
* Lists all graphs known to the graph module
*
* @see API
* Documentation
* @return graphs stored in this database
* @throws ArangoDBException
*/
Collection getGraphs() throws ArangoDBException;
/**
* Execute a server-side transaction
*
* @see API
* Documentation
* @param action
* the actual transaction operations to be executed, in the form of stringified JavaScript code
* @param type
* The type of the result (POJO class, VPackSlice or String for Json)
* @param options
* Additional options, can be null
* @return the result of the transaction if it succeeded
* @throws ArangoDBException
*/
T transaction(final String action, final Class type, final TransactionOptions options)
throws ArangoDBException;
/**
* Retrieves information about the current database
*
* @see API
* Documentation
* @return information about the current database
* @throws ArangoDBException
*/
DatabaseEntity getInfo() throws ArangoDBException;
/**
* Execute a server-side traversal
*
* @see API
* Documentation
* @param vertexClass
* The type of the vertex documents (POJO class, VPackSlice or String for Json)
* @param edgeClass
* The type of the edge documents (POJO class, VPackSlice or String for Json)
* @param options
* Additional options
* @return Result of the executed traversal
* @throws ArangoDBException
*/
TraversalEntity executeTraversal(
final Class vertexClass,
final Class edgeClass,
final TraversalOptions options) throws ArangoDBException;
/**
* Reads a single document
*
* @see API
* Documentation
* @param id
* The id of the document
* @param type
* The type of the document (POJO class, VPackSlice or String for Json)
* @return the document identified by the id
* @throws ArangoDBException
*/
T getDocument(final String id, final Class type) throws ArangoDBException;
/**
* Reads a single document
*
* @see API
* Documentation
* @param id
* The id of the document
* @param type
* The type of the document (POJO class, VPackSlice or String for Json)
* @param options
* Additional options, can be null
* @return the document identified by the id
* @throws ArangoDBException
*/
T getDocument(final String id, final Class type, final DocumentReadOptions options) throws ArangoDBException;
/**
* Reload the routing table.
*
* @see API
* Documentation
* @throws ArangoDBException
*/
void reloadRouting() throws ArangoDBException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy