Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 141 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2014,11 +2014,151 @@ Returns [`Promise<HTTP.Body>`](#body)

#### <a name="status">`cluster.status(conn)`</a>

Retrieves detailed status information about a Stardog cluster.
Retrieves detailed status information about a Stardog cluster.

Expects the following parameters:

- conn ([`Connection`](#connection))

Returns [`Promise<HTTP.Body>`](#body)

## <a name="datasources">dataSources</a>

#### <a name="list">`dataSources.list(conn)`</a>

Retrieve a list of data sources

Expects the following parameters:

- conn ([`Connection`](#connection))

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="listinfo">`dataSources.listInfo(conn)`</a>

Retrieve a list of data sources info

Expects the following parameters:

- conn ([`Connection`](#connection))

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="info">`dataSources.info(conn, name)`</a>

Retrieve the named data source info

Expects the following parameters:

- conn ([`Connection`](#connection))

- name (`string`)

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="add">`dataSources.add(conn, name, options)`</a>

Add a data source to the system

Expects the following parameters:

- conn ([`Connection`](#connection))

- name (`string`)

- options ([`T`](#t))

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="update">`dataSources.update(conn, name, options)`</a>

Update the named data source in the system

Expects the following parameters:

- conn ([`Connection`](#connection))

- name (`string`)

- options ([`T`](#t))

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="remove">`dataSources.remove(conn, name)`</a>

Remove the named data source from the system

Expects the following parameters:

- conn ([`Connection`](#connection))

- name (`string`)

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="online">`dataSources.online(conn, name)`</a>

Bring the named data source online

Expects the following parameters:

- conn ([`Connection`](#connection))

- name (`string`)

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="available">`dataSources.available(conn, name)`</a>

Determine if the named data source is available

Expects the following parameters:

- conn ([`Connection`](#connection))

- name (`string`)

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="options">`dataSources.options(conn, name)`</a>

Retrieve the named data source options

Expects the following parameters:

- conn ([`Connection`](#connection))

- name (`string`)

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="getmetadata">`dataSources.getMetadata(conn, name, options)`</a>

Retrieve the named data source metadata

Expects the following parameters:

- conn ([`Connection`](#connection))

- name (`string`)

- options (`object`)

Returns [`Promise<HTTP.Body>`](#body)

#### <a name="updatemetadata">`dataSources.updateMetadata(conn, name, metadata, options)`</a>

Update the named data source metadata

Expects the following parameters:

- conn ([`Connection`](#connection))

- name (`string`)

- metadata ([`T`](#t))

- options (`object`)

Returns [`Promise<HTTP.Body>`](#body)

117 changes: 117 additions & 0 deletions lib/dataSources.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
const { fetch } = require('./fetch');

const { httpBody } = require('./response-transforms');

const list = conn => {
const headers = conn.headers();
return fetch(conn.request('admin', 'data_sources'), {
headers,
}).then(httpBody);
};

const listInfo = conn => {
const headers = conn.headers();
return fetch(conn.request('admin', 'data_sources', 'list'), {
headers,
}).then(httpBody);
};

const info = (conn, name) => {
const headers = conn.headers();
headers.set('Content-Type', 'application/json');
return fetch(conn.request('admin', 'data_sources', name, 'info'), {
headers,
}).then(httpBody);
};

const add = (conn, name, options) => {
const headers = conn.headers();
headers.set('Content-Type', 'application/json');
return fetch(conn.request('admin', 'data_sources'), {
method: 'POST',
body: JSON.stringify({
name,
options,
}),
headers,
}).then(httpBody);
};

const update = (conn, name, options) => {
const headers = conn.headers();
headers.set('Content-Type', 'application/json');
return fetch(conn.request('admin', 'data_sources', name), {
method: 'PUT',
body: JSON.stringify({
name,
options,
}),
headers,
}).then(httpBody);
};

const remove = (conn, name) => {
const headers = conn.headers();
return fetch(conn.request('admin', 'data_sources', name), {
method: 'DELETE',
headers,
}).then(httpBody);
};

const online = (conn, name) => {
const headers = conn.headers();
headers.set('Accept', 'application/json');
return fetch(conn.request('admin', 'data_sources', name, 'online'), {
method: 'POST',
headers,
}).then(httpBody);
};

const available = (conn, name) => {
const headers = conn.headers();
headers.set('Accept', 'application/json');
return fetch(conn.request('admin', 'data_sources', name, 'available'), {
headers,
}).then(httpBody);
};

const options = (conn, name) => {
const headers = conn.headers();
return fetch(conn.request('admin', 'data_sources', name, 'options'), {
headers,
}).then(httpBody);
};

const getMetadata = (conn, name, opts = {}) => {
const headers = conn.headers();
headers.set('Accept', opts.accept || 'text/turtle');

return fetch(conn.request('admin', 'data_sources', name, 'metadata'), {
headers,
}).then(httpBody);
};

const updateMetadata = (conn, name, metadata, opts = {}) => {
const headers = conn.headers();
headers.set('Content-Type', opts.contentType || 'text/turtle');

return fetch(conn.request('admin', 'data_sources', name, 'metadata'), {
method: 'PUT',
body: metadata,
headers,
}).then(httpBody);
};

module.exports = {
list,
listInfo,
info,
add,
update,
remove,
online,
available,
options,
getMetadata,
updateMetadata,
};
95 changes: 94 additions & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1282,12 +1282,105 @@ declare namespace Stardog {
function info(conn: Connection): Promise<HTTP.Body>;

/**
* Retrieves detailed status information about a Stardog cluster.
* Retrieves detailed status information about a Stardog cluster.
*
* @param {Connection} conn the Stardog server connection
*/
function status(conn: Connection): Promise<HTTP.Body>;
}

export namespace dataSources {
/**
* Retrieve a list of data sources
*
* @param {Connection} conn the Stardog server connection
*/
function list(conn: Connection): Promise<HTTP.Body>;

/**
* Retrieve a list of data sources info
*
* @param {Connection} conn the Stardog server connection
*/
function listInfo(conn: Connection): Promise<HTTP.Body>;

/**
* Retrieve the named data source info
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the data source name
*/
function info(conn: Connection, name: string): Promise<HTTP.Body>;

/**
* Add a data source to the system
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the data source name
* @param {Options} options the JDBC (and other) options for the data source
*/
function add<T>(conn: Connection, name: string, options: T): Promise<HTTP.Body>;

/**
* Update the named data source in the system
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the data source name
* @param {Options} options the JDBC (and other) options for the data source
*/
function update<T>(conn: Connection, name: string, options: T): Promise<HTTP.Body>;

/**
* Remove the named data source from the system
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the data source name
*/
function remove(conn: Connection, name: string): Promise<HTTP.Body>;

/**
* Bring the named data source online
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the data source name
*/
function online(conn: Connection, name: string): Promise<HTTP.Body>;

/**
* Determine if the named data source is available
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the data source name
*/
function available(conn: Connection, name: string): Promise<HTTP.Body>;

/**
* Retrieve the named data source options
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the data source name
*/
function options(conn: Connection, name: string): Promise<HTTP.Body>;

/**
* Retrieve the named data source metadata
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the data source name
* @param {object} options additional options if needed
*/
function getMetadata(conn: Connection, name: string, options: object): Promise<HTTP.Body>;

/**
* Update the named data source metadata
*
* @param {Connection} conn the Stardog server connection
* @param {string} name the data source name
* @param {Metadata} metadata the data source metadata
* @param {object} options additional options if needed
*/
function updateMetadata<T>(conn: Connection, name: string, metadata: T, options: object): Promise<HTTP.Body>;
}
}

// No idea why I need this, but this is what removes the extra level of nesting
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Stardog = {
cluster: require('./cluster'),
virtualGraphs: require('./virtualGraphs'),
storedFunctions: require('./storedFunctions'),
dataSources: require('./dataSources'),
};

module.exports = Stardog;
Loading