epp_client/host/
delete.rs1use super::XMLNS;
4use crate::common::{NoExtension, StringValue};
5use crate::request::{Command, Transaction};
6use serde::Serialize;
7
8impl<'a> Transaction<NoExtension> for HostDelete<'a> {}
9
10impl<'a> Command for HostDelete<'a> {
11 type Response = ();
12 const COMMAND: &'static str = "delete";
13}
14
15impl<'a> HostDelete<'a> {
16 pub fn new(name: &'a str) -> Self {
17 Self {
18 host: HostDeleteRequestData {
19 xmlns: XMLNS,
20 name: name.into(),
21 },
22 }
23 }
24}
25
26#[derive(Serialize, Debug)]
28pub struct HostDeleteRequestData<'a> {
29 #[serde(rename = "xmlns:host")]
31 xmlns: &'a str,
32 #[serde(rename = "host:name")]
34 name: StringValue<'a>,
35}
36
37#[derive(Serialize, Debug)]
38pub struct HostDelete<'a> {
40 #[serde(rename = "host:delete")]
42 host: HostDeleteRequestData<'a>,
43}
44
45#[cfg(test)]
46mod tests {
47 use super::HostDelete;
48 use crate::response::ResultCode;
49 use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
50
51 #[test]
52 fn command() {
53 let object = HostDelete::new("ns1.eppdev-1.com");
54 assert_serialized("request/host/delete.xml", &object);
55 }
56
57 #[test]
58 fn response() {
59 let object = response_from_file::<HostDelete>("response/host/delete.xml");
60 assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
61 assert_eq!(object.result.message, SUCCESS_MSG.into());
62 assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
63 assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
64 }
65}