Last active
May 22, 2018 18:52
-
-
Save cluther/dbb893a5b1c3aeece4a3f1d4304c18e4 to your computer and use it in GitHub Desktop.
Revisions
-
cluther revised this gist
May 22, 2018 . 2 changed files with 41 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ from Products.Zuul import getFacade class ResolveSysRouter(DirectRouter): """ JSON API router. This router is accessed via POST to a URL such as the following. https://zenoss5.example.com/zport/dmd/resolvesys_router With an application/json data such as the following. { "action": "ResolveSysRouter", "method": "updateEventDetails", "data": [ { "evid": "c0136587-0ce2-417f-94ce-2c13ab4c228a", "details": { "Zenoss.Resolve.Worksheet": "exhibit-a", "WhatIsThatServiceNowFieldCalled": "INC12345" } } ] } Note that the "resolvesys_router" portion of the URL comes from the name we give our "directRouter" in configure.zcml when we register it. """ def updateEventDetails(self, evid, **details): """Update event details of event identified by evid.""" # zep is the "Zenoss Event Processor" API. zep = getFacade("zep") # This is easy because we already have a method for it. zep.updateDetails(evid, **details) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,7 @@ xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser"> <!-- Register our custom JSON API endpoint (router). --> <browser:directRouter name="resolvesys_router" for="*" @@ -11,4 +12,4 @@ permission="Zenoss.View" /> </configure> -
cluther created this gist
May 22, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <configure xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser"> <browser:directRouter name="resolvesys_router" for="*" class=".api.ResolveSysRouter" namespace="Zenoss.remote" permission="Zenoss.View" /> </configure>