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

adding support to victorops #401

Merged
merged 29 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f72db5e
adding support for victor ops
alonm-totango Jul 11, 2021
0d94ebd
adding support for victor in the cli
alonm-totango Jul 11, 2021
6613b17
Merge branch 'master' of https://github.com/alonm-totango/notifiers
alonm-totango Jul 12, 2021
7c63e7d
schema format update
alonm-totango Jul 13, 2021
cd7f3e5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 13, 2021
18ff40d
fixing typos
alonm-totango Jul 15, 2021
71d0554
deprecation of flake8.
alonm-totango Jul 15, 2021
88f2352
fixing Flake8 errors:
alonm-totango Jul 15, 2021
8e96410
fixing PR review requests
alonm-totango Aug 2, 2021
f4bd117
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2021
e7053e2
adding tests
alonm-totango Aug 2, 2021
3aec4d6
Merge remote-tracking branch 'origin/master'
alonm-totango Aug 2, 2021
6c378b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2021
47af946
shortening line to past linter
alonm-totango Aug 2, 2021
5aff635
Merge remote-tracking branch 'origin/master'
alonm-totango Aug 2, 2021
7c6fefe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2021
f4654de
twining schema,
alonm-totango Aug 5, 2021
a7e7116
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 5, 2021
d15c5f5
twining schema,
alonm-totango Aug 5, 2021
34ccc8b
Merge remote-tracking branch 'origin/master'
alonm-totango Aug 5, 2021
08245a5
twining schema,
alonm-totango Aug 5, 2021
9ce706a
twining schema,
alonm-totango Aug 8, 2021
e23cf36
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 8, 2021
cbb39dc
twining schema,
alonm-totango Aug 9, 2021
60b2c72
Merge remote-tracking branch 'origin/master'
alonm-totango Aug 9, 2021
ae1f4c9
removing un necessary import
alonm-totango Aug 9, 2021
8bac1c0
make line ending nicer
alonm-totango Aug 10, 2021
4ef80f9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 10, 2021
7e54c34
Merge branch 'master' into master
liiight Aug 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions notifiers/providers/victorops.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from ..core import Provider
from ..core import Response
from ..utils import requests
from ..exceptions import SchemaError
import re


class VictorOps(Provider):
Expand Down Expand Up @@ -58,13 +60,13 @@ class VictorOps(Provider):
"annotations": {
"type": "object",
"patternProperties": {
"vo_annotate.u.": {"type": "string"},
"vo_annotate.s.": {"type": "string"},
"vo_annotate.i.": {"type": "string"},
"^vo_annotate.u.": {"type": "string"},
"^vo_annotate.s.": {"type": "string"},
"^vo_annotate.i.": {"type": "string"},
},
"minProperties": 1,
"title": "annotations can be of three types vo_annotate.u.Runbook, vo_annotate.s.Note, "
"vo_annotate.i.image.",
"title": "annotations can be of three types vo_annotate.u.{custom_name}, vo_annotate.s.{custom_name}, "
"vo_annotate.i.{custom_name} .",
alonm-totango marked this conversation as resolved.
Show resolved Hide resolved
},
"additional_keys": {
"type": "object",
Expand All @@ -77,7 +79,15 @@ class VictorOps(Provider):
def _prepare_data(self, data: dict) -> dict:
annotations = data.pop("annotations", {})
for annotation, value in annotations.items():
data[annotation] = value
if re.match(r"vo_annotate.[usi].", annotation):
alonm-totango marked this conversation as resolved.
Show resolved Hide resolved
data[annotation] = value
else:
error_message = "Validates provider schema for syntax issues. " \
"annotations must be one of the following " \
"vo_annotate.u.{custom_name}, vo_annotate.s.{custom_name}, vo_annotate.i.{custom_name}"
raise SchemaError(
schema_error=error_message, provider=self.name, data=self.schema
)

additional_keys = data.pop("additional_keys", {})
for additional_key, value in additional_keys.items():
Expand Down
8 changes: 4 additions & 4 deletions source/providers/victorops.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Full schema:
annotations:
type: object
format:
vo_annotate.s.Note: annotation
vo_annotate.u.Runbook: annotation
vo_annotate.i.Graph: annotation
title: annotations can be of three types vo_annotate.u.Runbook vo_annotate.s.Note vo_annotate.i.image.
vo_annotate.s.{custom_name}: annotation
vo_annotate.u.{custom_name}: annotation
vo_annotate.i.{custom_name}: annotation
title: annotations can be of three types vo_annotate.u.{custom_name} vo_annotate.s.{custom_name} vo_annotate.i.{custom_name}.

additional_keys:
type: object
Expand Down