graphdb
Version:
Javascript client library supporting GraphDB and RDF4J REST API.
225 lines (224 loc) • 10.6 kB
TypeScript
export = GraphDBServerClient;
/**
* Extends the {@link Server} with GraphDB API provided by GraphDB.
*
* Used to automate the security user management API:
* add, edit, or remove users. Also used to add, edit,
* or remove a repository to/from any attached location.
* You can work with multiple remote locations from a
* single access point.
*
* @class
* @author Teodossi Dossev
*
*/
declare class GraphDBServerClient extends Server {
/**
* Retrieves the list of repository IDs from the specified location.
*
* @param {string} [location] - Optional repository location. If provided,
* the request will be executed for
* the specified location.
* @return {Promise<string[]>} A promise that resolves to an array
* of repository IDs.
*/
getRepositoryIDs(location?: string): Promise<string[]>;
/**
* Checks if a repository with the provided ID exists.
*
* @param {string} id The ID of the repository to check.
* @param {string} [location] The location of the repository (optional).
*
* @return {Promise<boolean>} A promise that resolves with a boolean value
* indicating whether the repository exists.
*/
hasRepository(id: string, location?: string): Promise<boolean>;
/**
* Creates a repository client instance with the provided id and
* configuration.
* @param {string} id of the repository
* @param {RepositoryClientConfig} config for the overridable repository
* configuration.
* @return {Promise<RDFRepositoryClient>} promise which resolves with
* new RDFRepositoryClient instance.
*/
getRepository(id: string, config: RepositoryClientConfig): Promise<RDFRepositoryClient>;
/**
* Deletes the repository with the provided ID.
*
* @param {string} id The ID of the repository to delete.
* @param {string} [location] The location of the repository (optional).
*
* @return {Promise<any>} A promise that resolves with the result of
* the delete operation.
*/
deleteRepository(id: string, location?: string): Promise<any>;
/**
* Get the default repository configuration for the repository type
*
* @param {RepositoryType|String} repositoryType the type for which a
* default configuration is required
*
* @return {Promise<HttpResponse|Error>} a promise which resolves to response
* wrapper or rejects with error if thrown during execution.
*/
getDefaultConfig(repositoryType: RepositoryType | string): Promise<HttpResponse | Error>;
/**
* Retrieves the configuration of a repository.
*
* @param {string} repositoryId The ID of the repository whose configuration
* is to be retrieved.
* @param {string} [location] The optional location of the repository.
*
* @return {Promise<HttpResponse|string|Error>} A promise that resolves to
* the response wrapper, or rejects with an error if one occurs
* during the execution.
*/
getRepositoryConfig(repositoryId: string, location?: string): Promise<HttpResponse | string | Error>;
/**
* Download the repository configuration in turtle format
*
* @param {string} repositoryId the repository id
* @param {string} [location] optional repository location
*
* @return {Promise<string | any>} a service request that will resolve to a
* readable stream to which the client can subscribe and consume the emitted
* strings as soon as they are available. Resolves to turtle format.
*/
downloadRepositoryConfig(repositoryId: string, location?: string): Promise<string | any>;
/**
* Creates a repository based on the provided configuration.
*
* @param {RepositoryConfig} repositoryConfig The configuration of
* the repository to be created.
*
* @return {Promise<HttpResponse|Error>} A promise that resolves to
* the response wrapper, or rejects with an error if one occurs
* during execution.
*/
createRepository(repositoryConfig: typeof RepositoryConfig): Promise<HttpResponse | Error>;
/**
* Checks if GraphDB security is enabled.
* @return {Promise<HttpResponse|Error>} a promise which resolves
* to response wrapper or rejects with error if thrown during execution.
*/
isSecurityEnabled(): Promise<HttpResponse | Error>;
/**
* Enable or disable GraphDB security.
* @param {boolean} enabled <code>true</code> if security is enabled and
* <code>false</code> otherwise.
* @return {Promise<HttpResponse|Error>} a promise which resolves
* to response wrapper or rejects with error if thrown during execution.
*/
toggleSecurity(enabled: boolean): Promise<HttpResponse | Error>;
/**
* Enable or disable access to a predefined set of functionalities
* without having to log in.
* To use free access, you must have security enabled.
* Use with extreme caution, as the changes that are made to the
* application settings may possibly change the behavior of the
* GraphDB Workbench for the logged-in user or for all users
* if logged in as admin.
* @param {boolean} enabled <code>true</code> if free access is enabled and
* <code>false</code> otherwise.
* @param {string[]} authorities Array of read and/or write access rights
* described in the following template:
* <code>READ_REPO_{repository ID}</code> to grant repository read rights
* <code>WRITE_REPO_{repository ID}</code> to grant repository write rights
* @param {AppSettings} appSettings configure the default behavior
* of the GraphDB Workbench
* @return {Promise<HttpResponse|Error>} a promise which resolves
* to response wrapper or rejects with error if thrown during execution.
*/
updateFreeAccess(enabled: boolean, authorities: string[], appSettings: typeof AppSettings): Promise<HttpResponse | Error>;
/**
* Check if free access is enabled
* @return {Promise<HttpResponse|Error>} a promise which resolves
* to response wrapper or rejects with error if thrown during execution.
*/
getFreeAccess(): Promise<HttpResponse | Error>;
/**
* Create a user
* @param {string} username User name
* @param {string} password User password
* @param {string[]} [grantedAuthorities] Array of read and/or write access
* rights described in the following template:
* <code>READ_REPO_{repository ID}</code> to grant repository read rights
* <code>WRITE_REPO_{repository ID}</code> to grant repository write rights
* @param {AppSettings} [appSettings] configure the default behavior
* of the GraphDB Workbench
* @return {Promise<HttpResponse|Error>} a promise which resolves
* to response wrapper or rejects with error if thrown during execution.
*/
createUser(username: string, password: string, grantedAuthorities?: string[], appSettings?: typeof AppSettings): Promise<HttpResponse | Error>;
/**
* Edit user.
* Use with extreme caution, as the changes that are made to the
* application settings may possibly change the behavior of the
* GraphDB Workbench for the user.
* @param {string} username User name
* @param {string} [password] User password
* @param {string[]} [grantedAuthorities] Array of read and/or write access
* rights described in the following template:
* <code>READ_REPO_{repository ID}</code> to grant repository read rights
* <code>WRITE_REPO_{repository ID}</code> to grant repository write rights
* @param {AppSettings} [appSettings] configure the default behavior
* of the GraphDB Workbench
* @return {Promise<HttpResponse|Error>} a promise which resolves
* to response wrapper or rejects with error if thrown during execution.
*/
updateUser(username: string, password?: string, grantedAuthorities?: string[], appSettings?: typeof AppSettings): Promise<HttpResponse | Error>;
/**
* Change setting for a logged user.
* Use with extreme caution, as the changes that are made to the
* application settings may possibly change the behavior of the
* GraphDB Workbench for the user.
* @param {string} username User name
* @param {string} [password] User password
* @param {AppSettings} [appSettings] configure the default behavior
* of the GraphDB Workbench
* @return {Promise<HttpResponse|Error>} a promise which resolves
* to response wrapper or rejects with error if thrown during execution.
*/
updateUserData(username: string, password?: string, appSettings?: typeof AppSettings): Promise<HttpResponse | Error>;
/**
* Get a user
* @param {string} username User name
* @return {Promise<HttpResponse|Error>} a promise which resolves
* to response wrapper or rejects with error if thrown during execution.
*/
getUser(username: string): Promise<HttpResponse | Error>;
/**
* Deletes a user
* @param {string} username User name
* @return {Promise<HttpResponse|Error>} a promise which resolves
* to response wrapper or rejects with error if thrown during execution.
*/
deleteUser(username: string): Promise<HttpResponse | Error>;
/**
* @private
* @param {Object} object to get json from
* @return {string | {}} json representation of object
* or empty object if undefined
*/
private objectToJson;
/**
* Returns the query parameter for the repository location if it's provided,
* otherwise returns an empty string.
*
* @private
*
* @param {string} [location] The location of the repository.
*
* @return {string} The query string representing the location parameter,
* or an empty string if the location is null or undefined.
*/
private getLocationParameter;
}
import Server = require("./server");
import RepositoryClientConfig = require("../repository/repository-client-config");
import RDFRepositoryClient = require("../repository/rdf-repository-client");
import RepositoryType = require("../repository/repository-type");
import HttpResponse = require("../http/http-response");
import RepositoryConfig = require("../repository/repository-config");
import AppSettings = require("./app-settings");