1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* 1MSG WhatsApp Business API (Public)
*
* Public client API for sending messages, managing groups, flows, and templates. This is the API exposed to end customers via platform.1msg.io **Authentication:** Pass the channel token in **one** place. The API checks JSON body (`token`), then query string (`?token=`), then `Authorization: Bearer` header (preferred in production). **Documentation:** https://help.1msg.io/platform-1msg/getting-start/quick-start **API Docs:** https://docs.1msg.io/
*
* The version of the OpenAPI document: 2.0.0
* Contact: support@1msg.io
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// WebhookUrlStatus : Circuit / auto-disable status for one configured webhook URL. The breaker is per URL (`instanceId` + URL hash), not per channel.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebhookUrlStatus {
/// This webhook URL (same string as in `webhookUrl`)
#[serde(rename = "url")]
pub url: String,
/// Delivery state for this URL only. `ok` delivering; `degraded` recent qualifying fails (still delivering, warning email on the 2nd fail); `open` skipping most deliveries pending a probe; `half_open` probe in flight (resume only on HTTP 2xx); `disabled` sticky auto-disabled until self-serve re-enable (`POST /webhook` / `POST /settings` with this URL) or a successful probe before sticky disable.
#[serde(rename = "circuitState")]
pub circuit_state: CircuitState,
/// Last qualifying fail reason, e.g. `http_404` or `timeout_or_network`
#[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
/// Diagnostic only — safe for clients to ignore. Number of qualifying delivery failures in the rolling ~10 minute breaker window (not lifetime, not \"how many times the customer retried\"). Prefer `circuitState` / `disabledWebhooks`.
#[serde(rename = "fails", skip_serializing_if = "Option::is_none")]
pub fails: Option<i32>,
/// Diagnostic only — safe for clients to ignore. How many recovery probes already failed for this URL. Probes run on a schedule (≈15 min → 1 h → 6 h); sticky disable after 3 failed probes. The 6 h step is the last probe, not a blind \"unblock in 6 hours\" timer.
#[serde(rename = "trips", skip_serializing_if = "Option::is_none")]
pub trips: Option<i32>,
/// Epoch milliseconds when this URL became sticky-disabled
#[serde(rename = "disabledAt", skip_serializing_if = "Option::is_none")]
pub disabled_at: Option<i32>,
/// Diagnostic only. Epoch ms of the first fail in the current ~10 minute window (pairs with `fails`; not a customer-facing period).
#[serde(rename = "firstFailAt", skip_serializing_if = "Option::is_none")]
pub first_fail_at: Option<i32>,
/// Last HTTP status from this URL, when known
#[serde(rename = "lastStatus", skip_serializing_if = "Option::is_none")]
pub last_status: Option<i32>,
/// Epoch milliseconds of the next half-open probe, if any
#[serde(rename = "nextProbeAt", skip_serializing_if = "Option::is_none")]
pub next_probe_at: Option<i32>,
}
impl WebhookUrlStatus {
/// Circuit / auto-disable status for one configured webhook URL. The breaker is per URL (`instanceId` + URL hash), not per channel.
pub fn new(url: String, circuit_state: CircuitState) -> WebhookUrlStatus {
WebhookUrlStatus {
url,
circuit_state,
reason: None,
fails: None,
trips: None,
disabled_at: None,
first_fail_at: None,
last_status: None,
next_probe_at: None,
}
}
}
/// Delivery state for this URL only. `ok` delivering; `degraded` recent qualifying fails (still delivering, warning email on the 2nd fail); `open` skipping most deliveries pending a probe; `half_open` probe in flight (resume only on HTTP 2xx); `disabled` sticky auto-disabled until self-serve re-enable (`POST /webhook` / `POST /settings` with this URL) or a successful probe before sticky disable.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum CircuitState {
#[serde(rename = "ok")]
Ok,
#[serde(rename = "degraded")]
Degraded,
#[serde(rename = "open")]
Open,
#[serde(rename = "half_open")]
HalfOpen,
#[serde(rename = "disabled")]
Disabled,
}
impl Default for CircuitState {
fn default() -> CircuitState {
Self::Ok
}
}