1use crate::{Client, ClientError, proto};
2
3pub struct Initial;
4pub struct WithKey;
5
6pub trait ResolveIncidentRequestState {}
7impl ResolveIncidentRequestState for Initial {}
8impl ResolveIncidentRequestState for WithKey {}
9
10#[derive(Debug, Clone)]
25pub struct ResolveIncidentRequest<T: ResolveIncidentRequestState> {
26 client: Client,
27 incident_key: i64,
28 operation_reference: Option<u64>,
29 _state: std::marker::PhantomData<T>,
30}
31
32impl<T: ResolveIncidentRequestState> ResolveIncidentRequest<T> {
33 pub(crate) fn new(client: Client) -> ResolveIncidentRequest<Initial> {
34 ResolveIncidentRequest {
35 client,
36 incident_key: 0,
37 operation_reference: None,
38 _state: std::marker::PhantomData,
39 }
40 }
41
42 fn transition<NewState: ResolveIncidentRequestState>(self) -> ResolveIncidentRequest<NewState> {
43 ResolveIncidentRequest {
44 client: self.client,
45 incident_key: self.incident_key,
46 operation_reference: self.operation_reference,
47 _state: std::marker::PhantomData,
48 }
49 }
50}
51
52impl ResolveIncidentRequest<Initial> {
53 pub fn with_incident_key(mut self, incident_key: i64) -> ResolveIncidentRequest<WithKey> {
63 self.incident_key = incident_key;
64 self.transition()
65 }
66}
67
68impl ResolveIncidentRequest<WithKey> {
69 pub async fn send(mut self) -> Result<ResolveIncidentResponse, ClientError> {
80 let res = self
81 .client
82 .gateway_client
83 .resolve_incident(proto::ResolveIncidentRequest {
84 incident_key: self.incident_key,
85 operation_reference: self.operation_reference,
86 })
87 .await?;
88
89 Ok(res.into_inner().into())
90 }
91
92 pub fn with_operation_reference(mut self, operation_reference: u64) -> Self {
102 self.operation_reference = Some(operation_reference);
103 self
104 }
105}
106
107#[derive(Debug, Clone)]
109pub struct ResolveIncidentResponse {}
110
111impl From<proto::ResolveIncidentResponse> for ResolveIncidentResponse {
112 fn from(_value: proto::ResolveIncidentResponse) -> ResolveIncidentResponse {
113 ResolveIncidentResponse {}
114 }
115}