bigpanda_rs/
change.rs

1use crate::{BigPandaError, Client, POST};
2use hyper::Body;
3use serde::Serialize;
4use std::collections::HashMap;
5
6const CHANGE_URL: &str = "https://api.bigpanda.io/data/changes";
7
8/// Change Payload
9/// See https://docs.bigpanda.io/reference#create-or-update-a-change for more details.
10#[derive(Serialize, Debug)]
11pub struct Change {
12    /// The change's unique identifier from its original change system.
13    pub identifier: String,
14
15    /// Status of the change. Choose one: [Planned,In Progress,Done,Canceled].
16    pub status: String,
17
18    /// Short summary/title of the change.
19    pub summary: String,
20
21    /// Start time of the change in Unix Epochs.
22    pub start: i64,
23
24    /// End time of the change in Unix Epochs.
25    pub end: i64,
26
27    /// (Optional) The URL of the record in the change system.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub ticket_url: Option<String>,
30
31    /// (Optional) JSON object that keeps a record of all tags. Visible in the UI in the Related Changes tab..
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub tags: Option<HashMap<String, String>>,
34
35    /// (Optional) JSON object that saves any data that's not in the UI.
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub metadata: Option<HashMap<String, String>>,
38}
39
40impl Client {
41    pub async fn send_change(&self, change: Change) -> Result<(), BigPandaError> {
42        self.send_request(
43            POST,
44            CHANGE_URL,
45            Body::from(serde_json::to_string(&change).unwrap()),
46        )
47        .await
48    }
49}