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
//! The hooks API.
use crate::models::{HookDeliveryId, HookId};
use crate::Octocrab;
mod list_deliveries;
mod retry_delivery;
pub use self::{list_deliveries::ListHooksDeliveriesBuilder, retry_delivery::RetryDeliveryBuilder};
/// A client to GitHub's webhooks API.
///
/// Created with [`Octocrab::hooks`].
pub struct HooksHandler<'octo> {
crab: &'octo Octocrab,
owner: String,
repo: Option<String>,
}
impl<'octo> HooksHandler<'octo> {
pub(crate) fn new(crab: &'octo Octocrab, owner: String) -> Self {
Self {
crab,
owner,
repo: None,
}
}
pub fn repo(mut self, repo: String) -> Self {
self.repo = Some(repo);
self
}
/// Lists all of the `Delivery`s associated with the hook.
/// ```no_run
/// # async fn run() -> octocrab::Result<()> {
/// let reviews = octocrab::instance()
/// .hooks("owner")
/// //.repo("repo")
/// .list_deliveries(21u64.into())
/// .per_page(100)
/// .page(2u32)
/// .send()
/// .await?;
/// # Ok(())
/// # }
/// ```
pub fn list_deliveries(&self, hook_id: HookId) -> ListHooksDeliveriesBuilder<'_, '_> {
ListHooksDeliveriesBuilder::new(self, hook_id)
}
/// Retry a delivery.
/// ```no_run
/// # async fn run() -> octocrab::Result<()> {
/// let reviews = octocrab::instance()
/// .hooks("owner")
/// //.repo("repo")
/// .retry_delivery(20u64.into(), 21u64.into())
/// .send()
/// .await?;
/// # Ok(())
/// # }
/// ```
pub fn retry_delivery(
&self,
hook_id: HookId,
delivery_id: HookDeliveryId,
) -> RetryDeliveryBuilder<'_, '_> {
RetryDeliveryBuilder::new(self, hook_id, delivery_id)
}
}