Skip to content

Commit 0fa6244

Browse files
f-wrightAuto-format Bot
andauthored
Custom payloads for webhook alerts (#314)
This PR adds the ability to provide custom payloads for webhook alerts. It will be included in the 0.22.0 SDK release. --------- Co-authored-by: Auto-format Bot <[email protected]>
1 parent 8755f41 commit 0fa6244

19 files changed

+806
-6
lines changed

docs/docs/guide/9-alerts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ Consider configuring a "no queries submitted" alert to monitor system health. If
2424

2525
## Alert Mediums
2626

27-
Groundlight supports the following alerts via Email and Text Message (SMS), with webhook support coming soon.
27+
Groundlight supports the following alerts via Email, Text Message (SMS), and Webhooks.

generated/.openapi-generator/FILES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ docs/PaginatedDetectorList.md
4242
docs/PaginatedImageQueryList.md
4343
docs/PaginatedRuleList.md
4444
docs/PatchedDetectorRequest.md
45+
docs/PayloadTemplate.md
46+
docs/PayloadTemplateRequest.md
4547
docs/ROI.md
4648
docs/ROIRequest.md
4749
docs/ResultTypeEnum.md
@@ -107,6 +109,8 @@ groundlight_openapi_client/model/paginated_detector_list.py
107109
groundlight_openapi_client/model/paginated_image_query_list.py
108110
groundlight_openapi_client/model/paginated_rule_list.py
109111
groundlight_openapi_client/model/patched_detector_request.py
112+
groundlight_openapi_client/model/payload_template.py
113+
groundlight_openapi_client/model/payload_template_request.py
110114
groundlight_openapi_client/model/result_type_enum.py
111115
groundlight_openapi_client/model/roi.py
112116
groundlight_openapi_client/model/roi_request.py

generated/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ rule_request = RuleRequest(
9494
WebhookActionRequest(
9595
url="url_example",
9696
include_image=True,
97+
payload_template=None,
9798
),
9899
],
99100
) # RuleRequest |
@@ -171,6 +172,8 @@ Class | Method | HTTP request | Description
171172
- [PaginatedImageQueryList](docs/PaginatedImageQueryList.md)
172173
- [PaginatedRuleList](docs/PaginatedRuleList.md)
173174
- [PatchedDetectorRequest](docs/PatchedDetectorRequest.md)
175+
- [PayloadTemplate](docs/PayloadTemplate.md)
176+
- [PayloadTemplateRequest](docs/PayloadTemplateRequest.md)
174177
- [ROI](docs/ROI.md)
175178
- [ROIRequest](docs/ROIRequest.md)
176179
- [ResultTypeEnum](docs/ResultTypeEnum.md)

generated/docs/ActionsApi.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client:
6969
WebhookActionRequest(
7070
url="url_example",
7171
include_image=True,
72+
payload_template=None,
7273
),
7374
],
7475
) # RuleRequest |

generated/docs/PayloadTemplate.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# PayloadTemplate
2+
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**template** | **str** | |
8+
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# PayloadTemplateRequest
2+
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**template** | **str** | |
8+
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+
12+

generated/docs/WebhookAction.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**url** | **str** | |
88
**include_image** | **bool** | | [optional]
9+
**payload_template** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional]
910
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
1011

1112
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

generated/docs/WebhookActionRequest.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**url** | **str** | |
88
**include_image** | **bool** | | [optional]
9+
**payload_template** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional]
910
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
1011

1112
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
"""
2+
Groundlight API
3+
4+
Groundlight makes it simple to understand images. You can easily create computer vision detectors just by describing what you want to know using natural language. # noqa: E501
5+
6+
The version of the OpenAPI document: 0.18.2
7+
8+
Generated by: https://openapi-generator.tech
9+
"""
10+
11+
import re # noqa: F401
12+
import sys # noqa: F401
13+
14+
from groundlight_openapi_client.model_utils import ( # noqa: F401
15+
ApiTypeError,
16+
ModelComposed,
17+
ModelNormal,
18+
ModelSimple,
19+
cached_property,
20+
change_keys_js_to_python,
21+
convert_js_args_to_python_args,
22+
date,
23+
datetime,
24+
file_type,
25+
none_type,
26+
validate_get_composed_info,
27+
OpenApiModel,
28+
)
29+
from groundlight_openapi_client.exceptions import ApiAttributeError
30+
31+
32+
class PayloadTemplate(ModelNormal):
33+
"""NOTE: This class is auto generated by OpenAPI Generator.
34+
Ref: https://openapi-generator.tech
35+
36+
Do not edit the class manually.
37+
38+
Attributes:
39+
allowed_values (dict): The key is the tuple path to the attribute
40+
and the for var_name this is (var_name,). The value is a dict
41+
with a capitalized key describing the allowed value and an allowed
42+
value. These dicts store the allowed enum values.
43+
attribute_map (dict): The key is attribute name
44+
and the value is json key in definition.
45+
discriminator_value_class_map (dict): A dict to go from the discriminator
46+
variable value to the discriminator class name.
47+
validations (dict): The key is the tuple path to the attribute
48+
and the for var_name this is (var_name,). The value is a dict
49+
that stores validations for max_length, min_length, max_items,
50+
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
51+
inclusive_minimum, and regex.
52+
additional_properties_type (tuple): A tuple of classes accepted
53+
as additional properties values.
54+
"""
55+
56+
allowed_values = {}
57+
58+
validations = {}
59+
60+
@cached_property
61+
def additional_properties_type():
62+
"""
63+
This must be a method because a model may have properties that are
64+
of type self, this must run after the class is loaded
65+
"""
66+
return (
67+
bool,
68+
date,
69+
datetime,
70+
dict,
71+
float,
72+
int,
73+
list,
74+
str,
75+
none_type,
76+
) # noqa: E501
77+
78+
_nullable = False
79+
80+
@cached_property
81+
def openapi_types():
82+
"""
83+
This must be a method because a model may have properties that are
84+
of type self, this must run after the class is loaded
85+
86+
Returns
87+
openapi_types (dict): The key is attribute name
88+
and the value is attribute type.
89+
"""
90+
return {
91+
"template": (str,), # noqa: E501
92+
}
93+
94+
@cached_property
95+
def discriminator():
96+
return None
97+
98+
attribute_map = {
99+
"template": "template", # noqa: E501
100+
}
101+
102+
read_only_vars = {}
103+
104+
_composed_schemas = {}
105+
106+
@classmethod
107+
@convert_js_args_to_python_args
108+
def _from_openapi_data(cls, template, *args, **kwargs): # noqa: E501
109+
"""PayloadTemplate - a model defined in OpenAPI
110+
111+
Args:
112+
template (str):
113+
114+
Keyword Args:
115+
_check_type (bool): if True, values for parameters in openapi_types
116+
will be type checked and a TypeError will be
117+
raised if the wrong type is input.
118+
Defaults to True
119+
_path_to_item (tuple/list): This is a list of keys or values to
120+
drill down to the model in received_data
121+
when deserializing a response
122+
_spec_property_naming (bool): True if the variable names in the input data
123+
are serialized names, as specified in the OpenAPI document.
124+
False if the variable names in the input data
125+
are pythonic names, e.g. snake case (default)
126+
_configuration (Configuration): the instance to use when
127+
deserializing a file_type parameter.
128+
If passed, type conversion is attempted
129+
If omitted no type conversion is done.
130+
_visited_composed_classes (tuple): This stores a tuple of
131+
classes that we have traveled through so that
132+
if we see that class again we will not use its
133+
discriminator again.
134+
When traveling through a discriminator, the
135+
composed schema that is
136+
is traveled through is added to this set.
137+
For example if Animal has a discriminator
138+
petType and we pass in "Dog", and the class Dog
139+
allOf includes Animal, we move through Animal
140+
once using the discriminator, and pick Dog.
141+
Then in Dog, we will make an instance of the
142+
Animal class but this time we won't travel
143+
through its discriminator because we passed in
144+
_visited_composed_classes = (Animal,)
145+
"""
146+
147+
_check_type = kwargs.pop("_check_type", True)
148+
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
149+
_path_to_item = kwargs.pop("_path_to_item", ())
150+
_configuration = kwargs.pop("_configuration", None)
151+
_visited_composed_classes = kwargs.pop("_visited_composed_classes", ())
152+
153+
self = super(OpenApiModel, cls).__new__(cls)
154+
155+
if args:
156+
raise ApiTypeError(
157+
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments."
158+
% (
159+
args,
160+
self.__class__.__name__,
161+
),
162+
path_to_item=_path_to_item,
163+
valid_classes=(self.__class__,),
164+
)
165+
166+
self._data_store = {}
167+
self._check_type = _check_type
168+
self._spec_property_naming = _spec_property_naming
169+
self._path_to_item = _path_to_item
170+
self._configuration = _configuration
171+
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
172+
173+
self.template = template
174+
for var_name, var_value in kwargs.items():
175+
if (
176+
var_name not in self.attribute_map
177+
and self._configuration is not None
178+
and self._configuration.discard_unknown_keys
179+
and self.additional_properties_type is None
180+
):
181+
# discard variable.
182+
continue
183+
setattr(self, var_name, var_value)
184+
return self
185+
186+
required_properties = set([
187+
"_data_store",
188+
"_check_type",
189+
"_spec_property_naming",
190+
"_path_to_item",
191+
"_configuration",
192+
"_visited_composed_classes",
193+
])
194+
195+
@convert_js_args_to_python_args
196+
def __init__(self, template, *args, **kwargs): # noqa: E501
197+
"""PayloadTemplate - a model defined in OpenAPI
198+
199+
Args:
200+
template (str):
201+
202+
Keyword Args:
203+
_check_type (bool): if True, values for parameters in openapi_types
204+
will be type checked and a TypeError will be
205+
raised if the wrong type is input.
206+
Defaults to True
207+
_path_to_item (tuple/list): This is a list of keys or values to
208+
drill down to the model in received_data
209+
when deserializing a response
210+
_spec_property_naming (bool): True if the variable names in the input data
211+
are serialized names, as specified in the OpenAPI document.
212+
False if the variable names in the input data
213+
are pythonic names, e.g. snake case (default)
214+
_configuration (Configuration): the instance to use when
215+
deserializing a file_type parameter.
216+
If passed, type conversion is attempted
217+
If omitted no type conversion is done.
218+
_visited_composed_classes (tuple): This stores a tuple of
219+
classes that we have traveled through so that
220+
if we see that class again we will not use its
221+
discriminator again.
222+
When traveling through a discriminator, the
223+
composed schema that is
224+
is traveled through is added to this set.
225+
For example if Animal has a discriminator
226+
petType and we pass in "Dog", and the class Dog
227+
allOf includes Animal, we move through Animal
228+
once using the discriminator, and pick Dog.
229+
Then in Dog, we will make an instance of the
230+
Animal class but this time we won't travel
231+
through its discriminator because we passed in
232+
_visited_composed_classes = (Animal,)
233+
"""
234+
235+
_check_type = kwargs.pop("_check_type", True)
236+
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
237+
_path_to_item = kwargs.pop("_path_to_item", ())
238+
_configuration = kwargs.pop("_configuration", None)
239+
_visited_composed_classes = kwargs.pop("_visited_composed_classes", ())
240+
241+
if args:
242+
raise ApiTypeError(
243+
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments."
244+
% (
245+
args,
246+
self.__class__.__name__,
247+
),
248+
path_to_item=_path_to_item,
249+
valid_classes=(self.__class__,),
250+
)
251+
252+
self._data_store = {}
253+
self._check_type = _check_type
254+
self._spec_property_naming = _spec_property_naming
255+
self._path_to_item = _path_to_item
256+
self._configuration = _configuration
257+
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
258+
259+
self.template = template
260+
for var_name, var_value in kwargs.items():
261+
if (
262+
var_name not in self.attribute_map
263+
and self._configuration is not None
264+
and self._configuration.discard_unknown_keys
265+
and self.additional_properties_type is None
266+
):
267+
# discard variable.
268+
continue
269+
setattr(self, var_name, var_value)
270+
if var_name in self.read_only_vars:
271+
raise ApiAttributeError(
272+
f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate "
273+
"class with read only attributes."
274+
)

0 commit comments

Comments
 (0)