geoserver-node-client 1.4.8 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,10 +41,10 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
41
41
  value: (function () {
42
42
  var _getAllUsers = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
43
43
  var response, geoServerResponse;
44
- return _regenerator["default"].wrap(function _callee$(_context) {
44
+ return _regenerator["default"].wrap(function (_context) {
45
45
  while (1) switch (_context.prev = _context.next) {
46
46
  case 0:
47
- _context.next = 2;
47
+ _context.next = 1;
48
48
  return (0, _nodeFetch["default"])(this.url + 'security/usergroup/users.json', {
49
49
  credentials: 'include',
50
50
  method: 'GET',
@@ -52,20 +52,20 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
52
52
  Authorization: this.auth
53
53
  }
54
54
  });
55
- case 2:
55
+ case 1:
56
56
  response = _context.sent;
57
57
  if (response.ok) {
58
- _context.next = 8;
58
+ _context.next = 3;
59
59
  break;
60
60
  }
61
- _context.next = 6;
61
+ _context.next = 2;
62
62
  return (0, _geoserver.getGeoServerResponseText)(response);
63
- case 6:
63
+ case 2:
64
64
  geoServerResponse = _context.sent;
65
65
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
66
- case 8:
66
+ case 3:
67
67
  return _context.abrupt("return", response.json());
68
- case 9:
68
+ case 4:
69
69
  case "end":
70
70
  return _context.stop();
71
71
  }
@@ -89,8 +89,8 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
89
89
  key: "createUser",
90
90
  value: (function () {
91
91
  var _createUser = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(username, password) {
92
- var body, response, geoServerResponse;
93
- return _regenerator["default"].wrap(function _callee2$(_context2) {
92
+ var body, response, geoServerResponse, _t;
93
+ return _regenerator["default"].wrap(function (_context2) {
94
94
  while (1) switch (_context2.prev = _context2.next) {
95
95
  case 0:
96
96
  body = {
@@ -100,7 +100,7 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
100
100
  enabled: true
101
101
  }
102
102
  };
103
- _context2.next = 3;
103
+ _context2.next = 1;
104
104
  return (0, _nodeFetch["default"])(this.url + 'security/usergroup/users.json', {
105
105
  credentials: 'include',
106
106
  method: 'POST',
@@ -110,24 +110,24 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
110
110
  },
111
111
  body: JSON.stringify(body)
112
112
  });
113
- case 3:
113
+ case 1:
114
114
  response = _context2.sent;
115
115
  if (response.ok) {
116
- _context2.next = 13;
116
+ _context2.next = 5;
117
117
  break;
118
118
  }
119
- _context2.next = 7;
119
+ _context2.next = 2;
120
120
  return (0, _geoserver.getGeoServerResponseText)(response);
121
- case 7:
121
+ case 2:
122
122
  geoServerResponse = _context2.sent;
123
- _context2.t0 = response.status;
124
- _context2.next = _context2.t0 === 404 ? 11 : 12;
123
+ _t = response.status;
124
+ _context2.next = _t === 404 ? 3 : 4;
125
125
  break;
126
- case 11:
126
+ case 3:
127
127
  throw new _geoserver.GeoServerResponseError("User ".concat(username, " might already exists."), geoServerResponse);
128
- case 12:
128
+ case 4:
129
129
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
130
- case 13:
130
+ case 5:
131
131
  case "end":
132
132
  return _context2.stop();
133
133
  }
@@ -154,7 +154,7 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
154
154
  value: (function () {
155
155
  var _updateUser = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(username, password, enabled) {
156
156
  var body, response, geoServerResponse;
157
- return _regenerator["default"].wrap(function _callee3$(_context3) {
157
+ return _regenerator["default"].wrap(function (_context3) {
158
158
  while (1) switch (_context3.prev = _context3.next) {
159
159
  case 0:
160
160
  body = {
@@ -163,7 +163,7 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
163
163
  enabled: enabled
164
164
  }
165
165
  };
166
- _context3.next = 3;
166
+ _context3.next = 1;
167
167
  return (0, _nodeFetch["default"])(this.url + 'security/usergroup/user/' + username, {
168
168
  credentials: 'include',
169
169
  method: 'POST',
@@ -173,18 +173,18 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
173
173
  },
174
174
  body: JSON.stringify(body)
175
175
  });
176
- case 3:
176
+ case 1:
177
177
  response = _context3.sent;
178
178
  if (response.ok) {
179
- _context3.next = 9;
179
+ _context3.next = 3;
180
180
  break;
181
181
  }
182
- _context3.next = 7;
182
+ _context3.next = 2;
183
183
  return (0, _geoserver.getGeoServerResponseText)(response);
184
- case 7:
184
+ case 2:
185
185
  geoServerResponse = _context3.sent;
186
186
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
187
- case 9:
187
+ case 3:
188
188
  case "end":
189
189
  return _context3.stop();
190
190
  }
@@ -195,6 +195,52 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
195
195
  }
196
196
  return updateUser;
197
197
  }()
198
+ /**
199
+ * Deletes an existing user.
200
+ *
201
+ * @param {String} username The name of the user to be deleted
202
+ *
203
+ * @throws Error if request fails
204
+ */
205
+ )
206
+ }, {
207
+ key: "deleteUser",
208
+ value: (function () {
209
+ var _deleteUser = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(username) {
210
+ var response, geoServerResponse;
211
+ return _regenerator["default"].wrap(function (_context4) {
212
+ while (1) switch (_context4.prev = _context4.next) {
213
+ case 0:
214
+ _context4.next = 1;
215
+ return (0, _nodeFetch["default"])(this.url + 'security/usergroup/user/' + username, {
216
+ credentials: 'include',
217
+ method: 'DELETE',
218
+ headers: {
219
+ Authorization: this.auth
220
+ }
221
+ });
222
+ case 1:
223
+ response = _context4.sent;
224
+ if (response.ok) {
225
+ _context4.next = 3;
226
+ break;
227
+ }
228
+ _context4.next = 2;
229
+ return (0, _geoserver.getGeoServerResponseText)(response);
230
+ case 2:
231
+ geoServerResponse = _context4.sent;
232
+ throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
233
+ case 3:
234
+ case "end":
235
+ return _context4.stop();
236
+ }
237
+ }, _callee4, this);
238
+ }));
239
+ function deleteUser(_x6) {
240
+ return _deleteUser.apply(this, arguments);
241
+ }
242
+ return deleteUser;
243
+ }()
198
244
  /**
199
245
  * Associates the given role to the user.
200
246
  *
@@ -207,12 +253,12 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
207
253
  }, {
208
254
  key: "associateUserRole",
209
255
  value: (function () {
210
- var _associateUserRole = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(username, role) {
256
+ var _associateUserRole = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(username, role) {
211
257
  var response, geoServerResponse;
212
- return _regenerator["default"].wrap(function _callee4$(_context4) {
213
- while (1) switch (_context4.prev = _context4.next) {
258
+ return _regenerator["default"].wrap(function (_context5) {
259
+ while (1) switch (_context5.prev = _context5.next) {
214
260
  case 0:
215
- _context4.next = 2;
261
+ _context5.next = 1;
216
262
  return (0, _nodeFetch["default"])("".concat(this.url, "security/roles/role/").concat(role, "/user/").concat(username), {
217
263
  credentials: 'include',
218
264
  method: 'POST',
@@ -220,24 +266,24 @@ var SecurityClient = exports["default"] = /*#__PURE__*/function () {
220
266
  Authorization: this.auth
221
267
  }
222
268
  });
223
- case 2:
224
- response = _context4.sent;
269
+ case 1:
270
+ response = _context5.sent;
225
271
  if (response.ok) {
226
- _context4.next = 8;
272
+ _context5.next = 3;
227
273
  break;
228
274
  }
229
- _context4.next = 6;
275
+ _context5.next = 2;
230
276
  return (0, _geoserver.getGeoServerResponseText)(response);
231
- case 6:
232
- geoServerResponse = _context4.sent;
277
+ case 2:
278
+ geoServerResponse = _context5.sent;
233
279
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
234
- case 8:
280
+ case 3:
235
281
  case "end":
236
- return _context4.stop();
282
+ return _context5.stop();
237
283
  }
238
- }, _callee4, this);
284
+ }, _callee5, this);
239
285
  }));
240
- function associateUserRole(_x6, _x7) {
286
+ function associateUserRole(_x7, _x8) {
241
287
  return _associateUserRole.apply(this, arguments);
242
288
  }
243
289
  return associateUserRole;
@@ -41,10 +41,10 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
41
41
  value: (function () {
42
42
  var _getSettings = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
43
43
  var response, geoServerResponse;
44
- return _regenerator["default"].wrap(function _callee$(_context) {
44
+ return _regenerator["default"].wrap(function (_context) {
45
45
  while (1) switch (_context.prev = _context.next) {
46
46
  case 0:
47
- _context.next = 2;
47
+ _context.next = 1;
48
48
  return (0, _nodeFetch["default"])(this.url + 'settings.json', {
49
49
  credentials: 'include',
50
50
  method: 'GET',
@@ -52,20 +52,20 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
52
52
  Authorization: this.auth
53
53
  }
54
54
  });
55
- case 2:
55
+ case 1:
56
56
  response = _context.sent;
57
57
  if (response.ok) {
58
- _context.next = 8;
58
+ _context.next = 3;
59
59
  break;
60
60
  }
61
- _context.next = 6;
61
+ _context.next = 2;
62
62
  return (0, _geoserver.getGeoServerResponseText)(response);
63
- case 6:
63
+ case 2:
64
64
  geoServerResponse = _context.sent;
65
65
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
66
- case 8:
66
+ case 3:
67
67
  return _context.abrupt("return", response.json());
68
- case 9:
68
+ case 4:
69
69
  case "end":
70
70
  return _context.stop();
71
71
  }
@@ -87,10 +87,10 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
87
87
  value: (function () {
88
88
  var _updateSettings = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(settings) {
89
89
  var response, geoServerResponse;
90
- return _regenerator["default"].wrap(function _callee2$(_context2) {
90
+ return _regenerator["default"].wrap(function (_context2) {
91
91
  while (1) switch (_context2.prev = _context2.next) {
92
92
  case 0:
93
- _context2.next = 2;
93
+ _context2.next = 1;
94
94
  return (0, _nodeFetch["default"])(this.url + 'settings', {
95
95
  credentials: 'include',
96
96
  method: 'PUT',
@@ -100,18 +100,18 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
100
100
  },
101
101
  body: JSON.stringify(settings)
102
102
  });
103
- case 2:
103
+ case 1:
104
104
  response = _context2.sent;
105
105
  if (response.ok) {
106
- _context2.next = 8;
106
+ _context2.next = 3;
107
107
  break;
108
108
  }
109
- _context2.next = 6;
109
+ _context2.next = 2;
110
110
  return (0, _geoserver.getGeoServerResponseText)(response);
111
- case 6:
111
+ case 2:
112
112
  geoServerResponse = _context2.sent;
113
113
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
114
- case 8:
114
+ case 3:
115
115
  case "end":
116
116
  return _context2.stop();
117
117
  }
@@ -133,24 +133,24 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
133
133
  value: (function () {
134
134
  var _updateProxyBaseUrl = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(proxyBaseUrl) {
135
135
  var settingsJson;
136
- return _regenerator["default"].wrap(function _callee3$(_context3) {
136
+ return _regenerator["default"].wrap(function (_context3) {
137
137
  while (1) switch (_context3.prev = _context3.next) {
138
138
  case 0:
139
- _context3.next = 2;
139
+ _context3.next = 1;
140
140
  return this.getSettings();
141
- case 2:
141
+ case 1:
142
142
  settingsJson = _context3.sent;
143
143
  if (!(!settingsJson.global && !settingsJson.global.settings)) {
144
- _context3.next = 5;
144
+ _context3.next = 2;
145
145
  break;
146
146
  }
147
147
  return _context3.abrupt("return", false);
148
- case 5:
148
+ case 2:
149
149
  // add proxyBaseUrl to settings
150
150
  settingsJson.global.settings.proxyBaseUrl = proxyBaseUrl;
151
- _context3.next = 8;
151
+ _context3.next = 3;
152
152
  return this.updateSettings(settingsJson);
153
- case 8:
153
+ case 3:
154
154
  case "end":
155
155
  return _context3.stop();
156
156
  }
@@ -174,10 +174,10 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
174
174
  value: (function () {
175
175
  var _getContactInformation = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
176
176
  var response, geoServerResponse;
177
- return _regenerator["default"].wrap(function _callee4$(_context4) {
177
+ return _regenerator["default"].wrap(function (_context4) {
178
178
  while (1) switch (_context4.prev = _context4.next) {
179
179
  case 0:
180
- _context4.next = 2;
180
+ _context4.next = 1;
181
181
  return (0, _nodeFetch["default"])(this.url + 'settings/contact', {
182
182
  credentials: 'include',
183
183
  method: 'GET',
@@ -185,20 +185,20 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
185
185
  Authorization: this.auth
186
186
  }
187
187
  });
188
- case 2:
188
+ case 1:
189
189
  response = _context4.sent;
190
190
  if (response.ok) {
191
- _context4.next = 8;
191
+ _context4.next = 3;
192
192
  break;
193
193
  }
194
- _context4.next = 6;
194
+ _context4.next = 2;
195
195
  return (0, _geoserver.getGeoServerResponseText)(response);
196
- case 6:
196
+ case 2:
197
197
  geoServerResponse = _context4.sent;
198
198
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
199
- case 8:
199
+ case 3:
200
200
  return _context4.abrupt("return", response.json());
201
- case 9:
201
+ case 4:
202
202
  case "end":
203
203
  return _context4.stop();
204
204
  }
@@ -232,7 +232,7 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
232
232
  value: (function () {
233
233
  var _updateContactInformation = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(address, city, country, postalCode, state, email, organization, contactPerson, phoneNumber) {
234
234
  var contact, body, url, response, geoServerResponse;
235
- return _regenerator["default"].wrap(function _callee5$(_context5) {
235
+ return _regenerator["default"].wrap(function (_context5) {
236
236
  while (1) switch (_context5.prev = _context5.next) {
237
237
  case 0:
238
238
  contact = {
@@ -250,7 +250,7 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
250
250
  contact: contact
251
251
  };
252
252
  url = this.url + 'settings/contact';
253
- _context5.next = 5;
253
+ _context5.next = 1;
254
254
  return (0, _nodeFetch["default"])(url, {
255
255
  credentials: 'include',
256
256
  method: 'PUT',
@@ -260,18 +260,18 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
260
260
  },
261
261
  body: JSON.stringify(body)
262
262
  });
263
- case 5:
263
+ case 1:
264
264
  response = _context5.sent;
265
265
  if (response.ok) {
266
- _context5.next = 11;
266
+ _context5.next = 3;
267
267
  break;
268
268
  }
269
- _context5.next = 9;
269
+ _context5.next = 2;
270
270
  return (0, _geoserver.getGeoServerResponseText)(response);
271
- case 9:
271
+ case 2:
272
272
  geoServerResponse = _context5.sent;
273
273
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
274
- case 11:
274
+ case 3:
275
275
  case "end":
276
276
  return _context5.stop();
277
277
  }