diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs index cd6f265..bdc3f80 100644 --- a/epp-client/src/epp.rs +++ b/epp-client/src/epp.rs @@ -5,7 +5,6 @@ pub mod request; pub mod response; pub mod xml; -pub use request::host::check::*; pub use request::host::create::*; pub use request::host::delete::*; pub use request::host::info::*; @@ -13,7 +12,6 @@ pub use request::host::update::*; pub use request::message::ack::*; pub use request::message::poll::*; -pub use response::host::check::*; pub use response::host::create::*; pub use response::host::delete::*; pub use response::host::info::*; diff --git a/epp-client/src/epp/request/host.rs b/epp-client/src/epp/request/host.rs index bf155e4..e2c1847 100644 --- a/epp-client/src/epp/request/host.rs +++ b/epp-client/src/epp/request/host.rs @@ -1,6 +1,5 @@ //! Types for EPP host requests -pub mod check; pub mod create; pub mod delete; pub mod info; diff --git a/epp-client/src/epp/response/host.rs b/epp-client/src/epp/response/host.rs index 52fbdcf..2852dbb 100644 --- a/epp-client/src/epp/response/host.rs +++ b/epp-client/src/epp/response/host.rs @@ -1,6 +1,5 @@ //! Types for EPP host responses -pub mod check; pub mod create; pub mod delete; pub mod info; diff --git a/epp-client/src/epp/response/host/check.rs b/epp-client/src/epp/response/host/check.rs deleted file mode 100644 index 4cbee92..0000000 --- a/epp-client/src/epp/response/host/check.rs +++ /dev/null @@ -1,49 +0,0 @@ -//! Types for EPP host check response - -use serde::{Deserialize, Serialize}; - -use crate::epp::object::{EppObject, StringValue}; -use crate::epp::response::CommandResponse; - -/// Type that represents the <epp> tag for the EPP XML host check response -pub type EppHostCheckResponse = EppObject>; - -/// Type that represents the <name> tag for host check response -#[derive(Serialize, Deserialize, Debug)] -pub struct HostCheck { - /// The host name - #[serde(rename = "$value")] - pub name: StringValue, - /// The host (un)availability - #[serde(rename = "avail")] - pub available: u16, -} - -/// Type that represents the <cd> tag for host check response -#[derive(Serialize, Deserialize, Debug)] -pub struct HostCheckDataItem { - /// Data under the <name> tag - #[serde(rename = "name")] - pub host: HostCheck, - /// The reason for (un)availability - pub reason: Option, -} - -/// Type that represents the <chkData> tag for host check response -#[derive(Serialize, Deserialize, Debug)] -pub struct HostCheckData { - /// XML namespace for host response data - #[serde(rename = "xmlns:host")] - xmlns: String, - /// Data under the <cd> tag - #[serde(rename = "cd")] - pub host_list: Vec, -} - -/// Type that represents the <resData> tag for host check response -#[derive(Serialize, Deserialize, Debug)] -pub struct HostCheckResult { - /// Data under the <chkData> tag - #[serde(rename = "chkData")] - pub check_data: HostCheckData, -} diff --git a/epp-client/src/host.rs b/epp-client/src/host.rs new file mode 100644 index 0000000..3e8ff0f --- /dev/null +++ b/epp-client/src/host.rs @@ -0,0 +1 @@ +pub mod check; diff --git a/epp-client/src/epp/request/host/check.rs b/epp-client/src/host/check.rs similarity index 63% rename from epp-client/src/epp/request/host/check.rs rename to epp-client/src/host/check.rs index a7b27a7..0d792a7 100644 --- a/epp-client/src/epp/request/host/check.rs +++ b/epp-client/src/host/check.rs @@ -4,6 +4,7 @@ use epp_client_macros::*; use crate::epp::object::{ElementName, EppObject, StringValue}; use crate::epp::request::Command; +use crate::epp::response::CommandResponse; use crate::epp::xml::EPP_HOST_XMLNS; use serde::{Deserialize, Serialize}; @@ -16,7 +17,7 @@ use serde::{Deserialize, Serialize}; /// /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; -/// use epp_client::epp::{EppHostCheck, EppHostCheckResponse}; +/// use epp_client::host::check::{EppHostCheck, EppHostCheckResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] @@ -56,7 +57,28 @@ use serde::{Deserialize, Serialize}; /// client.logout().await.unwrap(); /// } /// ``` -pub type EppHostCheck = EppObject>; +pub type EppHostCheck = EppObject>; + +impl EppHostCheck { + /// Creates a new EppObject for host check corresponding to the <epp> tag in EPP XML + pub fn new(hosts: &[&str], client_tr_id: &str) -> EppHostCheck { + let hosts = hosts.iter().map(|&d| d.into()).collect(); + + let host_check = HostCheckRequest { + list: HostList { + xmlns: EPP_HOST_XMLNS.to_string(), + hosts, + }, + }; + + EppObject::build(Command::::new(host_check, client_tr_id)) + } +} + +/// Type that represents the <epp> tag for the EPP XML host check response +pub type EppHostCheckResponse = EppObject>; + +// Request /// Type for data under the host <check> tag #[derive(Serialize, Deserialize, Debug)] @@ -72,24 +94,50 @@ pub struct HostList { #[derive(Serialize, Deserialize, Debug, ElementName)] #[element_name(name = "check")] /// Type for EPP XML <check> command for hosts -pub struct HostCheck { +pub struct HostCheckRequest { /// The instance holding the list of hosts to be checked #[serde(rename = "host:check", alias = "check")] list: HostList, } -impl EppHostCheck { - /// Creates a new EppObject for host check corresponding to the <epp> tag in EPP XML - pub fn new(hosts: &[&str], client_tr_id: &str) -> EppHostCheck { - let hosts = hosts.iter().map(|&d| d.into()).collect(); +// Response - let host_check = HostCheck { - list: HostList { - xmlns: EPP_HOST_XMLNS.to_string(), - hosts, - }, - }; - - EppObject::build(Command::::new(host_check, client_tr_id)) - } +/// Type that represents the <name> tag for host check response +#[derive(Serialize, Deserialize, Debug)] +pub struct HostCheck { + /// The host name + #[serde(rename = "$value")] + pub name: StringValue, + /// The host (un)availability + #[serde(rename = "avail")] + pub available: u16, +} + +/// Type that represents the <cd> tag for host check response +#[derive(Serialize, Deserialize, Debug)] +pub struct HostCheckDataItem { + /// Data under the <name> tag + #[serde(rename = "name")] + pub host: HostCheck, + /// The reason for (un)availability + pub reason: Option, +} + +/// Type that represents the <chkData> tag for host check response +#[derive(Serialize, Deserialize, Debug)] +pub struct HostCheckData { + /// XML namespace for host response data + #[serde(rename = "xmlns:host")] + xmlns: String, + /// Data under the <cd> tag + #[serde(rename = "cd")] + pub host_list: Vec, +} + +/// Type that represents the <resData> tag for host check response +#[derive(Serialize, Deserialize, Debug)] +pub struct HostCheckResult { + /// Data under the <chkData> tag + #[serde(rename = "chkData")] + pub check_data: HostCheckData, } diff --git a/epp-client/src/lib.rs b/epp-client/src/lib.rs index f61333b..f2a4569 100644 --- a/epp-client/src/lib.rs +++ b/epp-client/src/lib.rs @@ -106,6 +106,7 @@ pub mod contact; pub mod domain; pub mod epp; pub mod error; +pub mod host; pub use connection::client::EppClient; #[cfg(test)] diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 4794a78..d06a6b8 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -27,6 +27,7 @@ mod response { }; use crate::epp::xml::EppXml; use crate::epp::*; + use crate::host::check::EppHostCheckResponse; const SVTRID: &str = "RO-6879-1627224678242975"; const SUCCESS_MSG: &str = "Command completed successfully"; diff --git a/epp-client/src/tests/se.rs b/epp-client/src/tests/se.rs index f66a803..4cd3418 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -30,6 +30,7 @@ mod request { use crate::epp::request::{EppHello, EppLogin, EppLogout}; use crate::epp::xml::EppXml; use crate::epp::*; + use crate::host::check::EppHostCheck; use chrono::{DateTime, NaiveDate}; use std::str::FromStr;