Order output, add docs, add support for 'all_tenants' flag
Implements: blueprint configurable-notifications Change-Id: Idcfa76012370e29eae94a29b4be268f3d0373c00
This commit is contained in:
@@ -171,6 +171,10 @@ You'll find complete documentation on the shell by running
|
|||||||
template show Template show
|
template show Template show
|
||||||
template validate
|
template validate
|
||||||
topology show Show the topology of the system
|
topology show Show the topology of the system
|
||||||
|
webhook add Add a new webhook to DB
|
||||||
|
webhook delete Delete a webhook
|
||||||
|
webhook list List all webhooks in DB
|
||||||
|
webhook show Show a webhook
|
||||||
|
|
||||||
Bash Completion
|
Bash Completion
|
||||||
---------------
|
---------------
|
||||||
@@ -824,6 +828,65 @@ To remove the created host alarm, field ``status`` should be ``up``::
|
|||||||
|
|
||||||
vitrage event post --type 'just.another.alarm.name' --details '{"hostname": "compute-0-0","source": "sample_monitor","cause": "another alarm","severity": "critical","status":"up","monitor_id": "sample monitor","monitor_event_id": "456"}'
|
vitrage event post --type 'just.another.alarm.name' --details '{"hostname": "compute-0-0","source": "sample_monitor","cause": "another alarm","severity": "critical","status":"up","monitor_id": "sample monitor","monitor_event_id": "456"}'
|
||||||
|
|
||||||
|
|
||||||
|
Webhook Example
|
||||||
|
---------------
|
||||||
|
Note: To see complete usage: 'vitrage help' and 'vitrage help <command>'
|
||||||
|
|
||||||
|
webhook list::
|
||||||
|
|
||||||
|
vitrage webhook list
|
||||||
|
|
||||||
|
+--------------------------------------+----------------------------+----------------------------------+---------------------------+--------------------------------------+------------------------+
|
||||||
|
| ID | Created At | Project ID | URL | Headers | Filter |
|
||||||
|
+--------------------------------------+----------------------------+----------------------------------+---------------------------+--------------------------------------+------------------------+
|
||||||
|
| 1e35dddf-ab0b-46ec-b0cc-0cf48129fc43 | 2018-01-10T14:27:09.000000 | dbec2ffbf3844eaa9d3c75dabf5777d8 | https://www.myurl.com | {'content-type': 'application/json'} | {'vitrage_type': '.*'} |
|
||||||
|
| bdc9edfa-d18c-4a18-9e03-2beb51402be0 | 2018-01-10T14:29:04.000000 | dbec2ffbf3844eaa9d3c75dabf5777d8 | https://hookb.in/Z1dxPre8 | | |
|
||||||
|
+--------------------------------------+----------------------------+----------------------------------+---------------------------+--------------------------------------+------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
webhook show::
|
||||||
|
|
||||||
|
vitrage webhook show c35caf11-f34d-440e-a804-0c1a4fdfb95b
|
||||||
|
|
||||||
|
+--------------+--------------------------------------+
|
||||||
|
| Field | Value |
|
||||||
|
+--------------+--------------------------------------+
|
||||||
|
| created_at | 2018-01-04T12:27:47.000000 |
|
||||||
|
| headers | None |
|
||||||
|
| id | c35caf11-f34d-440e-a804-0c1a4fdfb95b |
|
||||||
|
| regex_filter | {'name':'e2e.*'} |
|
||||||
|
| updated_at | None |
|
||||||
|
| url | https://requestb.in/tq3fkvtq |
|
||||||
|
+--------------+--------------------------------------+
|
||||||
|
|
||||||
|
webhook delete::
|
||||||
|
|
||||||
|
vitrage webhook delete c35caf11-f34d-440e-a804-0c1a4fdfb95b
|
||||||
|
|
||||||
|
+---------+------------------------------------------------------+
|
||||||
|
| Field | Value |
|
||||||
|
+---------+------------------------------------------------------+
|
||||||
|
| SUCCESS | Webhook c35caf11-f34d-440e-a804-0c1a4fdfb95b deleted |
|
||||||
|
+---------+------------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
webhook add::
|
||||||
|
|
||||||
|
vitrage webhook add --url https://www.myurl.com --headers
|
||||||
|
"{'content-type': 'application/json'}" --regex_filter "{'vitrage_type':'.*'}"
|
||||||
|
|
||||||
|
+--------------+--------------------------------------+
|
||||||
|
| Field | Value |
|
||||||
|
+--------------+--------------------------------------+
|
||||||
|
| created_at | 2018-01-04 14:32:23.489253 |
|
||||||
|
| headers | {'content-type': 'application/json'} |
|
||||||
|
| id | 2bd3ba88-f1fc-4917-bb69-bf0d1ff02d35 |
|
||||||
|
| regex_filter | {'vitrage_type': '.*'} |
|
||||||
|
| url | https://www.myurl.com |
|
||||||
|
+--------------+--------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
Python API
|
Python API
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ from vitrageclient.common import utils
|
|||||||
|
|
||||||
# noinspection PyAbstractClass
|
# noinspection PyAbstractClass
|
||||||
class WebhookShow(show.ShowOne):
|
class WebhookShow(show.ShowOne):
|
||||||
"""Show a webhook destination with "id" """
|
"""Show a webhook """
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(WebhookShow, self).get_parser(prog_name)
|
parser = super(WebhookShow, self).get_parser(prog_name)
|
||||||
@@ -27,29 +27,41 @@ class WebhookShow(show.ShowOne):
|
|||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
id = parsed_args.id
|
id = parsed_args.id
|
||||||
post_registration = utils.get_client(self).webhook.show(id=id)
|
webhook = utils.get_client(self).webhook.show(id=id)
|
||||||
return self.dict2columns(post_registration)
|
return self.dict2columns(webhook)
|
||||||
|
|
||||||
|
|
||||||
class WebhookList(lister.Lister):
|
class WebhookList(lister.Lister):
|
||||||
"""List all webhook destinations in DB"""
|
"""List all webhooks in DB"""
|
||||||
|
|
||||||
POST_PROPS = \
|
POST_PROPS = \
|
||||||
('created_at', 'id', 'url', 'headers', 'regex_filter')
|
(
|
||||||
|
('ID', 'id'),
|
||||||
|
('Created At', 'created_at'),
|
||||||
|
('Project ID', 'project_id'),
|
||||||
|
('URL', 'url'),
|
||||||
|
('Headers', 'headers'),
|
||||||
|
('Filter', 'regex_filter')
|
||||||
|
)
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(WebhookList, self).get_parser(prog_name)
|
parser = super(WebhookList, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('--all-tenants',
|
||||||
|
default=False,
|
||||||
|
dest='all_tenants',
|
||||||
|
action='store_true',
|
||||||
|
help='Shows webhooks of all the tenants')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
post_registrations = utils.get_client(self).webhook.list()
|
all_tenants = parsed_args.all_tenants
|
||||||
|
webhooks = utils.get_client(self).webhook.list(all_tenants=all_tenants)
|
||||||
|
|
||||||
return utils.list2cols(self.POST_PROPS, post_registrations)
|
return utils.list2cols_with_rename(self.POST_PROPS, webhooks)
|
||||||
|
|
||||||
|
|
||||||
class WebhookAdd(show.ShowOne):
|
class WebhookAdd(show.ShowOne):
|
||||||
"""Add a new webhook registration to DB"""
|
"""Add a new webhook to DB"""
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(WebhookAdd, self).get_parser(prog_name)
|
parser = super(WebhookAdd, self).get_parser(prog_name)
|
||||||
parser.add_argument('--url',
|
parser.add_argument('--url',
|
||||||
@@ -78,7 +90,7 @@ class WebhookAdd(show.ShowOne):
|
|||||||
|
|
||||||
|
|
||||||
class WebhookDelete(show.ShowOne):
|
class WebhookDelete(show.ShowOne):
|
||||||
"""Delete a webhook destination with "id" """
|
"""Delete a webhook """
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(WebhookDelete, self).get_parser(prog_name)
|
parser = super(WebhookDelete, self).get_parser(prog_name)
|
||||||
|
@@ -20,9 +20,10 @@ class Webhook(object):
|
|||||||
def __init__(self, api):
|
def __init__(self, api):
|
||||||
self.api = api
|
self.api = api
|
||||||
|
|
||||||
def list(self):
|
def list(self, all_tenants=False):
|
||||||
"""Get webhook list"""
|
"""Get webhook list"""
|
||||||
return self.api.get(self.url).json()
|
params = dict(all_tenants=all_tenants)
|
||||||
|
return self.api.get(self.url, params=params).json()
|
||||||
|
|
||||||
def show(self, id):
|
def show(self, id):
|
||||||
"""Show specific webhook
|
"""Show specific webhook
|
||||||
|
Reference in New Issue
Block a user