Commit graph

180 commits

Author SHA1 Message Date
Pēteris Caune
79da9e9f4f
Fix auto-fixable ruff warnings
(`ruff check --fix`)
2024-11-07 15:15:58 +02:00
Pēteris Caune
c91213179f
Fix API to gracefully handle too long slugs 2024-10-16 12:35:30 +03:00
Pēteris Caune
b2c5e91c70
Implement legacy -> canonical timezone conversion
There are three related changes:

* Removed legacy timezones from hc.lib.tz.all_timezones
* Added data migration to update existing Check.tz values
* For backwards compatibility, added code to automatically
  replace a legacy timezone with a canonical timezone when a
  legacy timezone is passed to an API call

I used the timezone mapping on
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
2024-06-14 12:55:57 +03:00
Pēteris Caune
52f2b534a6
Fix API to accept Europe/Kiev but save it as Europe/Kyiv 2024-06-13 15:23:27 +03:00
Pēteris Caune
638d11c969
Improve type hints 2024-03-05 17:18:55 +02:00
Pēteris Caune
af6731a24f
Fix code to use project.check_set instead of Check.objects.filter(...)
No functional difference, just cleaner.
2024-02-28 10:01:52 +02:00
Pēteris Caune
1322bb1123
Add support for per-check status badges
Fixes: #853
2024-02-27 12:55:51 +02:00
Pēteris Caune
54b8092be9
Fix mypy warnings 2023-12-07 14:44:31 +02:00
Pēteris Caune
fc56cf2635
Add API support for OnCalendar schedules 2023-12-07 14:03:35 +02:00
Pēteris Caune
fe67db5726
Fix the "Update Check" API call to handle concurrent deletes 2023-10-27 14:21:10 +03:00
Pēteris Caune
f962e869ba
Fix a race condition in concurrent "Delete Check" API calls 2023-10-27 13:36:47 +03:00
Pēteris Caune
9173475194
Improve type hints in hc.api.views 2023-09-07 14:38:55 +03:00
Pēteris Caune
a2fa62c7be
Improve function and variable names 2023-09-07 14:05:47 +03:00
Pēteris Caune
18aac7f46c
Update Spec model to handle int -> timedelta conversion 2023-09-07 13:19:21 +03:00
Pēteris Caune
53200a0559
Switch to using None as the sentinel object for absent fields
It means we need to have an extra checks for null values
in Spec.check_nulls() but it makes mypy more happy.
2023-09-07 12:56:35 +03:00
Pēteris Caune
370a75373b
Combine the "validate_json" and "authorize" decorators 2023-09-07 11:18:14 +03:00
Pēteris Caune
ee30448c0b
Update hc.api.views to use Pydantic for incoming data validation 2023-09-07 10:31:54 +03:00
Pēteris Caune
c9bf3132fe
Replace usage of typing.List, typing.Optional etc. with modern syntax 2023-09-06 11:27:43 +03:00
Pēteris Caune
774471e4e8
Improve type annotations in hc.api.views._update 2023-07-12 12:23:45 +03:00
Pēteris Caune
9c00938516
Update email bounce handler to log diagnostic codes 2023-07-06 15:21:02 +03:00
Pēteris Caune
651aec4ac7
Add API support for filtering checks by slug
Fixes: #844
2023-06-27 12:41:31 +03:00
Pēteris Caune
58d317adc7
Make check auto-provisioning opt-in
cc: #849, #626
2023-06-27 09:45:38 +03:00
Pēteris Caune
730d448c76
Fix pinging by slug to return 201 when a check is auto-created
cc: #849, #626
2023-06-26 13:06:20 +03:00
Pēteris Caune
3202eebbcf
Fix ping_by_slug to assign all channels to a newly created check 2023-06-15 15:53:33 +03:00
Pēteris Caune
fc09d4c084
Implement check auto-provisioning when pinging by slug
cc: #626
2023-06-15 15:36:16 +03:00
Pēteris Caune
4ccee09f73
Add /api/v3/ (adds ability to set slug when creating or updating checks) 2023-06-14 16:52:45 +03:00
Pēteris Caune
0fa9222264
Switch to case-insensitive bounce id signatures 2023-05-24 18:13:36 +03:00
Pēteris Caune
efc5bc0168
Improve the email delivery error message 2023-05-24 14:56:48 +03:00
Pēteris Caune
bb361dec7b
Add a view for handling email bounce notifications 2023-05-24 13:00:02 +03:00
Pēteris Caune
1fd343a820
Remove usages of django.utils.timezone.utc which is deprecated 2023-05-04 10:56:19 +03:00
Pēteris Caune
4e3034978f
Fix another instance of pinging/deleting race condition 2023-05-02 14:11:56 +03:00
Pēteris Caune
2eeb0b5471
Improve code comments 2023-05-02 13:25:16 +03:00
Pēteris Caune
6375b0aac4
Fix a race condition when pinging and deleting checks at the same time 2023-05-02 13:22:16 +03:00
Pēteris Caune
a9b084ec9a
Add "Start Keyword" filtering for inbound emails
Fixes: #716
2023-01-16 13:19:35 +02:00
Pēteris Caune
4863dda6c3
Add /api/v2/ which reports check's status slightly differently
cc: #633
2022-12-19 22:31:38 +02:00
Pēteris Caune
a65aa171f4
Replace var=[...];if var: [...] usages with the walrus operator 2022-12-01 09:16:19 +02:00
Pēteris Caune
c3e6fca6a7
Fix "get body" views to preserve body bytes, avoid string conversions 2022-11-28 14:48:55 +02:00
Pēteris Caune
ea2f2d9ec0
Add more tests 2022-11-28 14:04:57 +02:00
Martin Lablans
a55a2692dc
Allow to retrieve a ping's body (#737)
Add /api/v1/checks/<uuid>/pings/<n>/body endpoint for retrieving ping body (#737)
2022-11-28 13:21:26 +02:00
Pēteris Caune
75188e218e
Fix duration calculation in the "Get Pings" API call 2022-11-11 13:04:08 +02:00
Pēteris Caune
7458770b41
Improve alerting logic when run IDs are used
* Add Check.last_start_rid field
* Fill Check.last_start_rid on every start event
* Clear Check.last_start on every "fail" event
* Clear Check.last_start on success event if either case is true:
 - the event's rid matches Check.last_start_rid
 - the event does not specify rid

In human terms, the alerting logic will be: we track the
execution time of the most recent "start" event only. It would
take a major redesign to track the execution time of all
concurrent "start" events and send alerts when *any* of them
overshoots the time budget. So, whenever we see a "start" event,
the timer resets.

Example:

* 00:00 client sends start signal with rid=A, timer starts
* 00:10 client sends start signal with rid=B, timer resets
* 00:20 client sends success signal with rid=A, timer
  does not reset because rid A does not match the rid seen in
  the most recent start signal (it was B)
* 00:30 the grace time runs out, the check's status shows
  as started + failed

At this point the check can be reset to a healthy state in 3
different ways:

* send a success signal with rid=B
* send a failure signal with any rid value or without it
* send a success signal without a rid value
2022-11-09 19:01:22 +02:00
seidnerj
b6027fa126
Added support for a "run id" parameter (#722)
Add support for specifying a run ID via a "rid" query parameter

cc: #461
2022-11-08 11:34:26 +02:00
seidnerj
c82c1a3a4a
Added duration to ping details (#720)
* Added duration to ping details. This is useful on a device with a small screen, since the duration cannot be seen in the main view so now one can see it in the ping's details.
* Changed terms across the board from "delta" to "duration"
* timedelta is now consistently imported as "td" across the entire project (even in Django generated migration files)
2022-11-01 09:18:34 +02:00
Pēteris Caune
895e8e856a
Improve type hints 2022-10-20 12:24:50 +03:00
Pēteris Caune
e4a956679e
Move port scrubbing to hc.api.views.ping, add test case
cc: #714
2022-10-20 11:59:19 +03:00
Pēteris Caune
161430fb10
Sort imports and add "from __future__ import annotations" 2022-10-17 16:52:15 +03:00
Pēteris Caune
7ac8458b07
Optimize the "Get a List of Existing Checks" API call 2022-10-12 17:02:47 +03:00
Pēteris Caune
5a0bf4062f
Add API support for resuming paused checks
Fixes: #687
2022-08-04 14:00:46 +03:00
Pēteris Caune
47e624900f
Fix the pause views to create Flip objects
I found a bug in the downtime statistics calculation. The
scenario:

* at T=0 a check goes down
* at T=5 some time later the user pauses it
* at T=10 the check receives a ping and goes up

If we don't record a status change (a flip) at T=5, then
the calculated total downtime will come out wrong (10)

This change fixes the pause views (hc.api.views.pause,
hc.front.views.pause) to create Flip objects.
2022-08-04 12:20:06 +03:00
Pēteris Caune
cd087d2fbf
Add API support for enabling/disabling filtering in message body
Specifically, add read/write support for the new fields:

* success_kw
* failure_kw
* filter_subject
* filter_body

The API still supports reading/writing the "subject" and
"subject_fail" fields, but these are now marked as deprecated
in API documentation.

Fixes: #653
2022-07-15 13:04:41 +03:00