Skip to main content

ephemeris_forge_forgejo/operation/
webhooks.rs

1use std::fmt;
2
3use crate::api::request::{CreateHookOption, EditHookOption};
4
5/// One write to the repository's webhooks.
6#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum Operation {
8    /// Create a webhook with its complete desired body.
9    Create {
10        /// The delivery URL.
11        url: String,
12        /// The request body.
13        body: CreateHookOption,
14    },
15    /// Edit an existing webhook.
16    Patch {
17        /// The webhook's identifier.
18        id: i64,
19        /// The delivery URL.
20        url: String,
21        /// The request body.
22        edit: EditHookOption,
23    },
24    /// Delete a webhook.
25    Delete {
26        /// The webhook's identifier.
27        id: i64,
28        /// The delivery URL, or the identifier when the hook has none.
29        url: String,
30    },
31}
32
33impl fmt::Display for Operation {
34    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35        match self {
36            Self::Create { url, body: _ }
37            | Self::Patch {
38                id: _,
39                url,
40                edit: _,
41            }
42            | Self::Delete { id: _, url } => write!(f, "webhook {url}"),
43        }
44    }
45}