-
Notifications
You must be signed in to change notification settings - Fork 16
/
geoserver-rest-client.js
57 lines (54 loc) · 2.94 KB
/
geoserver-rest-client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import LayerClient from './src/layer.js';
import StyleClient from './src/style.js';
import WorkspaceClient from './src/workspace.js';
import DatastoreClient from './src/datastore.js';
import ImageMosaicClient from './src/imagemosaic.js';
import SecurityClient from './src/security.js';
import SettingsClient from './src/settings.js';
import NamespaceClient from './src/namespace.js';
import AboutClient from './src/about.js';
import ResetReloadClient from './src/reset-reload.js';
import LayerGroupClient from './src/layergroup.js';
export { GeoServerResponseError } from './src/util/geoserver.js'
/**
* Client for GeoServer REST API.
* Has minimal basic functionality and offers REST client instances for
* sub-entities, like workspaces or datastores as member variables.
*
* @module GeoServerRestClient
*/
export class GeoServerRestClient {
/**
* Creates a GeoServerRestClient instance.
*
* @param {String} url The URL of the GeoServer REST API endpoint
* @param {String} user The user for the GeoServer REST API
* @param {String} password The password for the GeoServer REST API
*/
constructor (url, user, password) {
this.url = url.endsWith('/') ? url : url + '/';
this.auth = 'Basic ' + Buffer.from(user + ':' + password).toString('base64');
/** @member {LayerClient} layers GeoServer REST client instance for layers */
this.layers = new LayerClient(this.url, this.auth);
/** @member {LayerGroupClient} layers GeoServer REST client instance for layergroups */
this.layergroups = new LayerGroupClient(this.url, this.auth);
/** @member {StyleClient} styles GeoServer REST client instance for styles */
this.styles = new StyleClient(this.url, this.auth);
/** @member {WorkspaceClient} workspaces GeoServer REST client instance for workspaces */
this.workspaces = new WorkspaceClient(this.url, this.auth);
/** @member {NamespaceClient} namespaces GeoServer REST client instance for namespaces */
this.namespaces = new NamespaceClient(this.url, this.auth);
/** @member {DatastoreClient} datastores GeoServer REST client instance for data stores */
this.datastores = new DatastoreClient(this.url, this.auth);
/** @member {ImageMosaicClient} imagemosaics GeoServer REST client instance for image mosaics */
this.imagemosaics = new ImageMosaicClient(this.url, this.auth);
/** @member {SecurityClient} security GeoServer REST client instance for security related modifications */
this.security = new SecurityClient(this.url, this.auth);
/** @member {SettingsClient} settings GeoServer REST client instance for settings */
this.settings = new SettingsClient(this.url, this.auth);
/** @member {AboutClient} about GeoServer REST client instance for about endpoint */
this.about = new AboutClient(this.url, this.auth);
/** @member {ResetReloadClient} about GeoServer REST client instance for reset/reload endpoints */
this.resetReload = new ResetReloadClient(this.url, this.auth);
}
}