User Tools
development:rapid_public_service_deployment
Rapid Public Service Deployment
Author: Andrey Shevyakov
Description: A quick guide on how to implement an SnmpManager Grails service with which a client GUI can interact (regardless of the selected GUI framework).
Steps:
- Create a Grails service implementing the DomainInteractor trait that will provide the following CRUD methods:
- getDomainInstance()
- getDomainInstanceBulk()
- newDomainInstance()
- newDomainInstanceBulk()
- updateDomainInstance()
- updateDomainInstanceBulk()
- deleteDomainInstance()
- deleteDomainInstanceBulk()
- In the service constructor, specify the following parameters (DomainInteraction trait):
- domainRefParam - key referring to the domain name (same as Class.simpleName) in the received map (params) - example: “domainName”
- domainEntriesRefParam - key referring to the entries collection in the received map (params) - example: “entriesToProcess”
- domainIdRefParam - key referring to the ID of a single domain entry to be affected in the received map (params) - example: “idToProcess”
- domainIdsRefParam - key referring to the IDs of the domain entries to be affected in the received map (params) - example: “idsToProcess”
- allowedDomains - names of the domains that are allowed for processing by the service - example: [“Carrier”, “DasHub”]
- Create a Grails controller extending the SecureController
- In the controller, implement a service accepting the client-sent JSON payload (must contain the keys specified in the Step 2 for the valid CRUD processing) and calling the relevant service method and returning the processing results to the client in the JSON format.
JSON-Request Example - Update CRUD:
var data = JSON.stringify({
'serviceAction' : 'updateDomainInstanceBulk',
'serviceDomain' : 'ResponsibilityType',
'serviceEntries' : [
{'id' : 30, 'name' : 'I was updated'},
{'id' : 27, 'name' : 'I was updated too'}
]
});
JSON-Response Example - Update CRUD:
{
"results": [
{
"id": 20,
"ResponsibilityType": {
"id": 20,
"name": "I was updated",
"class": "com.errigal.snmpmanager.knowledge.ResponsibilityType"
},
"success": true
},
{
"id": 22,
"ResponsibilityType": {
"id": 22,
"name": "I was updated too",
"class": "com.errigal.snmpmanager.knowledge.ResponsibilityType"
},
"success": true
}
],
"success": true
}
Diagrams:
development/rapid_public_service_deployment.txt · Last modified: 2021/06/25 10:09 by 127.0.0.1

