#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct WebhookPublicErrorCode {
    pub code: &'static str,
    pub status: u16,
    pub description: &'static str,
}

pub const WEBHOOK_ERROR_CODE_WEBHOOK_NOT_FOUND: &str = "webhook_not_found";
pub const WEBHOOK_ERROR_CODE_WEBHOOK_SINK_NOT_FOUND: &str = "webhook_sink_not_found";
pub const WEBHOOK_ERROR_CODE_WEBHOOK_SINK_PROVISION_FAILED: &str = "webhook_sink_provision_failed";

pub const WEBHOOK_PUBLIC_ERROR_CODES: &[WebhookPublicErrorCode] = &[
    WebhookPublicErrorCode {
        code: WEBHOOK_ERROR_CODE_WEBHOOK_NOT_FOUND,
        status: 404,
        description: "The requested gateway webhook definition does not exist.",
    },
    WebhookPublicErrorCode {
        code: WEBHOOK_ERROR_CODE_WEBHOOK_SINK_NOT_FOUND,
        status: 404,
        description: "The requested gateway webhook sink definition does not exist.",
    },
    WebhookPublicErrorCode {
        code: WEBHOOK_ERROR_CODE_WEBHOOK_SINK_PROVISION_FAILED,
        status: 500,
        description: "Athena could not persist the requested webhook sink definition set.",
    },
];

#[cfg(test)]
mod tests {
    use super::WEBHOOK_PUBLIC_ERROR_CODES;
    use std::collections::HashSet;

    #[test]
    fn public_webhook_error_codes_are_unique() {
        let mut seen = HashSet::new();
        for descriptor in WEBHOOK_PUBLIC_ERROR_CODES {
            assert!(
                seen.insert(descriptor.code),
                "duplicate webhook public error code: {}",
                descriptor.code
            );
        }
    }
}
