-
Notifications
You must be signed in to change notification settings - Fork 477
/
ConfigurationController.java
490 lines (466 loc) · 33.1 KB
/
ConfigurationController.java
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
/*
* Copyright 2014-2016 CyberVision, Inc.
*
* 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.
*/
package org.kaaproject.kaa.server.admin.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.kaaproject.kaa.common.dto.ConfigurationDto;
import org.kaaproject.kaa.common.dto.ConfigurationRecordDto;
import org.kaaproject.kaa.common.dto.ConfigurationSchemaDto;
import org.kaaproject.kaa.common.dto.EndpointSpecificConfigurationDto;
import org.kaaproject.kaa.common.dto.EndpointUserConfigurationDto;
import org.kaaproject.kaa.common.dto.VersionDto;
import org.kaaproject.kaa.server.admin.shared.services.KaaAdminServiceException;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import java.nio.charset.Charset;
import java.util.List;
@Api(value = "Configuration", description = "Provides function for manage configuration", basePath = "/kaaAdmin/rest")
@Controller
public class ConfigurationController extends AbstractAdminController {
private static final Charset DECODING_CHARSET = Charset.forName("ISO-8859-1");
/**
* Gets the configuration schemas by application token.
*
* @param applicationToken the application token
* @return the сonfiguration schema dto
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Get configuration schemas",
notes = "Returns all configuration schemas for the specified application. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " +
"to perform this operation. The application must be associated with the user who has submitted the request.")
@ApiResponses(value = {
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "Application with the specified applicationId does not exist"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configurationSchemas/{applicationToken}", method = RequestMethod.GET)
@ResponseBody
public List<ConfigurationSchemaDto> getConfigurationSchemasByApplicationToken(
@ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true)
@PathVariable String applicationToken)
throws KaaAdminServiceException {
return configurationService.getConfigurationSchemasByApplicationToken(applicationToken);
}
/**
* Gets the vacant configuration schemas by endpoint group id.
*
* @param endpointGroupId the endpoint group id
* @return the list schema dto
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Get vacant configuration schemas",
notes = "Returns all vacant (not being used by endpoint group configurations) configuration schemas for the specified endpoint group. Only users " +
"with the TENANT_DEVELOPER or TENANT_USER role are allowed to request this information.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "An endpoint group to be edited with the specified endpointGroupId does not exist"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "vacantConfigurationSchemas/{endpointGroupId}", method = RequestMethod.GET)
@ResponseBody
public List<VersionDto> getVacantConfigurationSchemasByEndpointGroupId(
@ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true)
@PathVariable String endpointGroupId)
throws KaaAdminServiceException {
return configurationService.getVacantConfigurationSchemasByEndpointGroupId(endpointGroupId);
}
/**
* Gets the configuration schema by her id.
*
* @param configurationSchemaId the сonfiguration schema id
* @return the сonfiguration schema dto
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Get configuration schema",
notes = "Returns a configuration schema by configuration schema ID. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " +
"to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "The configuration schema with the specified configurationSchemaId does not exist"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configurationSchema/{configurationSchemaId}", method = RequestMethod.GET)
@ResponseBody
public ConfigurationSchemaDto getConfigurationSchema(
@ApiParam(name = "configurationSchemaId", value = "A unique configuration schema identifier", required = true)
@PathVariable String configurationSchemaId) throws KaaAdminServiceException {
return configurationService.getConfigurationSchema(configurationSchemaId);
}
/**
* Adds configuration schema to the list of all configuration schemas.
*
* @param configurationSchema the сonfiguration schema
* @return the сonfiguration schema dto
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Create configuration schema",
notes = "Uploads a configuration schema. A unique version number will be generated (incrementally) for the uploaded schema, and the " +
"createUsername field of the schema will be set to the name of the user who uploaded it. Only users with the TENANT_DEVELOPER or " +
"TENANT_USER role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Specified configuration schema is not a valid avro schema"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "saveConfigurationSchema", method = RequestMethod.POST)
@ResponseBody
public ConfigurationSchemaDto saveConfigurationSchema(
@ApiParam(name = "configurationSchema", value = "ConfigurationSchemaDto body", required = true)
@RequestBody ConfigurationSchemaDto configurationSchema) throws KaaAdminServiceException {
return configurationService.saveConfigurationSchema(configurationSchema);
}
/**
* Gets the configuration records by endpoint group id.
*
* @param endpointGroupId the endpoint group id
* @param includeDeprecated the include deprecated
* @return the list configuration record dto
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Get configuration records",
notes = "Returns all configuration records for the specified endpoint group. Only users with the TENANT_DEVELOPER or TENANT_USER role are " +
"allowed to request this information.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configurationRecords", method = RequestMethod.GET)
@ResponseBody
public List<ConfigurationRecordDto> getConfigurationRecordsByEndpointGroupId(
@ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true)
@RequestParam(value = "endpointGroupId") String endpointGroupId,
@ApiParam(name = "includeDeprecated", value = "[“true” or ”false”] if “true”, all configuration records will be returned, including deprecated " +
"ones. If “false”, only active and inactive configuration records will be returned", required = true)
@RequestParam(value = "includeDeprecated") boolean includeDeprecated) throws KaaAdminServiceException {
return configurationService.getConfigurationRecordsByEndpointGroupId(endpointGroupId, includeDeprecated);
}
/**
* Gets the configuration record by schema id and endpoint group id.
*
* @param schemaId the schema id
* @param endpointGroupId the endpoint group id
* @return the configuration record dto
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Get configuration record",
notes = "Returns the configuration record for the specified endpoint group and configuration schema. Only users with the TENANT_DEVELOPER or " +
"TENANT_USER role are allowed to request this information.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or the endpoint group does not have the " +
"requested configuration record"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configurationRecord", method = RequestMethod.GET)
@ResponseBody
public ConfigurationRecordDto getConfigurationRecord(
@ApiParam(name = "schemaId", value = "A unique configuration schema identifier", required = true)
@RequestParam(value = "schemaId") String schemaId,
@ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true)
@RequestParam(value = "endpointGroupId") String endpointGroupId) throws KaaAdminServiceException {
return configurationService.getConfigurationRecord(schemaId, endpointGroupId);
}
@ApiOperation(value = "Get configuration record body",
notes = "Returns the configuration record string body for the specified endpoint group and configuration schema. Only users with the " +
"TENANT_DEVELOPER or TENANT_USER role are allowed to request this information.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or the endpoint group does not have the " +
"requested configuration record"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configurationRecordBody", params = {"schemaId", "endpointGroupId"}, method = RequestMethod.GET)
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public String getConfigurationRecordBody(
@ApiParam(name = "schemaId", value = "A unique configuration schema identifier", required = true)
@RequestParam(value = "schemaId") String schemaId,
@ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true)
@RequestParam("endpointGroupId") String endpointGroupId) throws KaaAdminServiceException {
String response = configurationService.getConfigurationRecord(schemaId, endpointGroupId).getActiveStructureDto().getBody();
String decodedResponse = new String(response.getBytes(), DECODING_CHARSET);
return decodedResponse;
}
/**
* Edits the configuration to the list of all configurations.
*
* @param configuration the configuration
* @return the configuration dto
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Create/Edit configuration",
notes = "Creates or updates a configuration. To create configuration you do not need to specify the configuration ID, createUsername field will " +
"be set to the name of the user who has uploaded it. To edit the configuration specify the configuration id. If a configuration with the " +
"specified ID exists, the configuration will be updated and its modifyUsername will be set to the user who has submitted the request. " +
"Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or a configuration with the specified " +
"configurationId not found"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configuration", method = RequestMethod.POST)
@ResponseBody
public ConfigurationDto editConfiguration(
@ApiParam(name = "configuration", value = "ConfigurationDto body. Mandatory fields: applicationId, schemaId, endpointGroupId, body", required = true)
@RequestBody ConfigurationDto configuration) throws KaaAdminServiceException {
return configurationService.editConfiguration(configuration);
}
/**
* Creates or updates a configuration for the specific user under the application.
*
* @param endpointUserConfiguration the endpoint user configuration
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Create/Edit user configuration",
notes = "Creates or updates a configuration for the specific user under the application. TIf a configuration with the specified user ID does not " +
"exist, then it will be created. If a configuration with the specified user ID exists, the configuration will be updated. Only users " +
"with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "A user with the specified userId or application with the specified appToken does not exists"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "userConfiguration", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void editUserConfiguration(
@ApiParam(name = "endpointUserConfiguration", value = "EndpointUserConfigurationDto body. Mandatory fields: userId, appToken, schemaVersion, " +
"body", required = true)
@RequestBody EndpointUserConfigurationDto endpointUserConfiguration) throws KaaAdminServiceException {
configurationService.editUserConfiguration(endpointUserConfiguration);
}
/**
* Creates or updates endpoint specific configuration by the endpoint key hash
*
* @param endpointSpecificConfiguration endpoint specific configuration
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Create or update endpoint specific configuration",
notes = "Creates or updates endpoint specific configuration. If a configuration for target endpoint does not " +
"exist, then it will be created. If a configuration for target endpoint exists, then it is updated. Only users " +
"with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Endpoint specific configuration created"),
@ApiResponse(code = 400, message = "Invalid input parameter provided"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "Specified endpoint does not exist"),
@ApiResponse(code = 409, message = "Can't update entity with provided version. Entity already changed"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "endpointConfiguration", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public EndpointSpecificConfigurationDto editEndpointSpecificConfiguration(
@ApiParam(name = "endpointSpecificConfiguration", value = "endpointSpecificConfigurationDto body. Mandatory fields: endpointKeyHash, configuration", required = true)
@RequestBody EndpointSpecificConfigurationDto endpointSpecificConfiguration) throws KaaAdminServiceException {
return configurationService.editEndpointSpecificConfiguration(endpointSpecificConfiguration);
}
/**
* Retrieves endpoint specific configuration by the endpoint key hash
*
* @param endpointKeyHash endpoint key hash
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Retrieve endpoint specific configuration",
notes = "Retrieves endpoint specific configuration by the endpoint key hash. If a configuration for provided endpoint key hash does not " +
"exist, then request is rejected. Only users " +
"with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Endpoint specific configuration successfully retrieved"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "Specified endpoint does not exist"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "endpointConfiguration/{endpointKeyHash}", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public EndpointSpecificConfigurationDto findEndpointSpecificConfiguration(
@PathVariable String endpointKeyHash) throws KaaAdminServiceException {
return configurationService.findEndpointSpecificConfiguration(endpointKeyHash);
}
/**
* Deletes endpoint specific configuration by the endpoint key hash
*
* @param endpointKeyHash endpoint key hash
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Delete endpoint specific configuration",
notes = "Deletes endpoint specific configuration by the endpoint key hash. If a configuration for provided endpoint key hash does not " +
"exist, then request is rejected. Only users " +
"with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Endpoint specific configuration successfully deleted"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "Specified endpoint does not exist"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "endpointConfiguration/{endpointKeyHash}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.OK)
public void deleteEndpointSpecificConfiguration(
@PathVariable String endpointKeyHash) throws KaaAdminServiceException {
configurationService.deleteEndpointSpecificConfiguration(endpointKeyHash);
}
/**
* Activate configuration by its id.
*
* @param configurationId the configuration id
* @return the configuration dto
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Activate configuration",
notes = "Activates a configuration. Sets the status field of the configuration to ACTIVE, increments the sequenceNumber field value by 1, and " +
"sets the activateUsername and activatedTime fields to the name of the user who has submitted the request and the activation time " +
"respectively. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "Configuration with the specified configurationId not found"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "activateConfiguration", method = RequestMethod.POST)
@ResponseBody
public ConfigurationDto activateConfiguration(
@ApiParam(name = "configurationId", value = "A unique configuration identifier", required = true)
@RequestBody String configurationId) throws KaaAdminServiceException {
return configurationService.activateConfiguration(configurationId);
}
/**
* Deactivate configuration by its id.
*
* @param configurationId the configuration id
* @return the configuration dto
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Deactivate configuration",
notes = "Deactivates a configuration. Sets the status field of the configuration to DEPRECATED, sets the deactivatedTime field value to the " +
"time of the deactivation request, and sets the deactivateUsername field to the name of the user who has submitted the request. " +
"Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "Configuration with the specified configurationId not found"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "deactivateConfiguration", method = RequestMethod.POST)
@ResponseBody
public ConfigurationDto deactivateConfiguration(
@ApiParam(name = "configurationId", value = "A unique configuration identifier", required = true)
@RequestBody String configurationId) throws KaaAdminServiceException {
return configurationService.deactivateConfiguration(configurationId);
}
/**
* Delete configuration record by schema id and endpoint group id.
*
* @param schemaId the schema id
* @param endpointGroupId the endpoint group id
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Delete configuration record",
notes = "Deletes a configuration record by configuration schema ID and endpoint group ID. Only users with the TENANT_DEVELOPER or TENANT_USER " +
"role are allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " +
"of the application does not match the Tenant ID of the authenticated user"),
@ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or the endpoint group does not have the " +
"requested configuration record"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "delConfigurationRecord", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void deleteConfigurationRecord(
@ApiParam(name = "schemaId", value = "A unique configuration schema identifier", required = true)
@RequestParam(value = "schemaId") String schemaId,
@ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true)
@RequestParam(value = "endpointGroupId") String endpointGroupId) throws KaaAdminServiceException {
configurationService.deleteConfigurationRecord(schemaId, endpointGroupId);
}
/**
* Get configuration of specific endpoint user bu externalUId
*
* @param appToken the application token
* @param schemaVersion the schema version
* @param externalUId the external user id
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Get endpoint user configuration by external user id",
notes="Get endpoint user configuration by external user id." +
" Only user with TENANT_DEVELOPER and TENANT_USER roles is allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The specified url is not valid"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have neither TENANT_DEVELOPER nor TENANT_USER role"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configuration/{externalUId}/{appToken}/{schemaVersion}", method = RequestMethod.GET)
@ResponseBody
public EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(
@ApiParam(name = "externalUId", value = "the external user id", required = true)
@PathVariable String externalUId,
@ApiParam(name = "appToken", value = "A unique application identifier", required = true)
@PathVariable String appToken,
@ApiParam(name = "schemaVersion", value = "The schema version", required = true)
@PathVariable Integer schemaVersion) throws KaaAdminServiceException {
return configurationService.findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(externalUId,appToken,schemaVersion);
}
/**
* Get configuration of specific endpoint by endpointKeyHash
*
* @param endpointKeyHash the endpoint key hash
* @throws KaaAdminServiceException the kaa admin service exception
*/
@ApiOperation(value = "Get configuration of specific endpoint by endpointKeyHash",
notes="Get configuration of specific endpoint by endpointKeyHash." +
" Only user with TENANT_DEVELOPER and TENANT_USER roles is allowed to perform this operation.")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "The specified url is not valid"),
@ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"),
@ApiResponse(code = 403, message = "The authenticated user does not have neither TENANT_DEVELOPER nor TENANT_USER role"),
@ApiResponse(code = 500, message = "An unexpected error occurred on the server side")})
@RequestMapping(value = "configuration/{endpointKeyHash}", method = RequestMethod.GET)
@ResponseBody
public String findEndpointConfigurationByEndpointKeyHash(
@ApiParam(name = "endpointKeyHash", value = "A unique identifier of the endpoint", required = true)
@PathVariable String endpointKeyHash) throws KaaAdminServiceException {
return configurationService.findEndpointConfigurationByEndpointKeyHash(endpointKeyHash);
}
}