Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Hooks" Concept #55

Open
coxley opened this issue Sep 10, 2015 · 3 comments
Open

"Hooks" Concept #55

coxley opened this issue Sep 10, 2015 · 3 comments

Comments

@coxley
Copy link
Contributor

coxley commented Sep 10, 2015

How rad would it be to have a hooks concept? I would like to maybe think about it in the next couple days to see if I could help add this functionality.

What 'design' would fit best into the nsot world? Something that allows you to set up hooks to get notified about each resource modification, creation, and deletion. Really as long as the resource object can be passed, each hook could take it from there at the basic level. At a more specific level it could be worked so you create a network-hook or a site-hook, but not sure if there'd be much extra value there.

Thoughts?

@jathanism
Copy link
Contributor

I love the idea, and since NSoT is built around Django which already has an underlying event hook system, we'd really have to capitalize on that on the server side.

And THEN we could implement that on the client side to make it easily usable.

@coxley
Copy link
Contributor Author

coxley commented Sep 10, 2015

I wonder what the best way to 'upload' hooks from the client would be.

@coxley
Copy link
Contributor Author

coxley commented Sep 19, 2015

Hooks functionality is now only blocked on unittests.

Please refer to the PR and NSoT Issue

We should work on getting this implemented from the client-side. Should be pretty easy.

Events

Events are defined in the conf/settings.py in nsot. Any resource that generates a Change record can be used with a hook, it just needs to be added to the relevant section in the Django config.

This is in the format of resource.signal, lowercased.

device.create
device.update
device.delete
network.create
site.create
...

Creating a hook

Payload:

{
    "event": "see list",
    "target": "http://url/to/post",
    "global_hook": true
}

POST http://[nsot]/api/hooks/

Updating a hook

Payload:

{
    "event": "see list",
    "target": "http://url/to/post",
    "global_hook": false
}

PUT http://[nsot]/api/hooks/[hook_id]/

Deleting a hook

DELETE http://[nsot]/api/hooks/[hook_id]/

Args

Arg Description
event Event to subscribe to
target Location to update everytime the chosen event happens
global_hook Bool. Global hooks ensure every change is posted regardless of which user submitted made the change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants