diff --git a/epp-client/src/epp.rs b/epp-client/src/epp.rs index 74875a7..e50c171 100644 --- a/epp-client/src/epp.rs +++ b/epp-client/src/epp.rs @@ -5,11 +5,9 @@ pub mod request; pub mod response; pub mod xml; -pub use request::host::update::*; pub use request::message::ack::*; pub use request::message::poll::*; -pub use response::host::update::*; pub use response::message::ack::*; pub use response::message::poll::*; diff --git a/epp-client/src/epp/request.rs b/epp-client/src/epp/request.rs index ef442b7..15b3d5b 100644 --- a/epp-client/src/epp/request.rs +++ b/epp-client/src/epp/request.rs @@ -1,6 +1,5 @@ //! Types for EPP requests -pub mod host; pub mod message; use serde::{ser::SerializeStruct, ser::Serializer, Deserialize, Serialize}; diff --git a/epp-client/src/epp/request/host.rs b/epp-client/src/epp/request/host.rs deleted file mode 100644 index 083e26b..0000000 --- a/epp-client/src/epp/request/host.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Types for EPP host requests - -pub mod update; diff --git a/epp-client/src/epp/response.rs b/epp-client/src/epp/response.rs index 8796b21..0806f27 100644 --- a/epp-client/src/epp/response.rs +++ b/epp-client/src/epp/response.rs @@ -1,6 +1,5 @@ //! Types for EPP responses -pub mod host; pub mod message; use epp_client_macros::*; diff --git a/epp-client/src/epp/response/host.rs b/epp-client/src/epp/response/host.rs deleted file mode 100644 index 5047054..0000000 --- a/epp-client/src/epp/response/host.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Types for EPP host responses - -pub mod update; diff --git a/epp-client/src/epp/response/host/update.rs b/epp-client/src/epp/response/host/update.rs deleted file mode 100644 index 43b5c14..0000000 --- a/epp-client/src/epp/response/host/update.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! Types for EPP host check response - -use crate::epp::response::EppCommandResponse; - -/// Type that represents the <epp> tag for the EPP XML host update response -pub type EppHostUpdateResponse = EppCommandResponse; diff --git a/epp-client/src/host.rs b/epp-client/src/host.rs index 770e8c7..035f812 100644 --- a/epp-client/src/host.rs +++ b/epp-client/src/host.rs @@ -2,3 +2,4 @@ pub mod check; pub mod create; pub mod delete; pub mod info; +pub mod update; diff --git a/epp-client/src/epp/request/host/update.rs b/epp-client/src/host/update.rs similarity index 90% rename from epp-client/src/epp/request/host/update.rs rename to epp-client/src/host/update.rs index 6b18594..9490ae6 100644 --- a/epp-client/src/epp/request/host/update.rs +++ b/epp-client/src/host/update.rs @@ -5,6 +5,7 @@ use epp_client_macros::*; use crate::epp::object::data::{HostAddr, HostStatus}; use crate::epp::object::{ElementName, EppObject, StringValue}; use crate::epp::request::Command; +use crate::epp::response::EppCommandResponse; use crate::epp::xml::EPP_HOST_XMLNS; use serde::{Deserialize, Serialize}; @@ -18,7 +19,7 @@ use serde::{Deserialize, Serialize}; /// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::object::data::{HostAddr, HostStatus}; -/// use epp_client::epp::{EppHostUpdate, EppHostUpdateResponse, HostAddRemove, HostChangeInfo}; +/// use epp_client::host::update::{EppHostUpdate, EppHostUpdateResponse, HostAddRemove, HostChangeInfo}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] @@ -76,62 +77,14 @@ use serde::{Deserialize, Serialize}; /// client.logout().await.unwrap(); /// } /// ``` -pub type EppHostUpdate = EppObject>; - -/// Type for data under the <chg> tag -#[derive(Serialize, Deserialize, Debug)] -pub struct HostChangeInfo { - /// The new name for the host - #[serde(rename = "host:name", alias = "name")] - pub name: StringValue, -} - -/// Type for data under the <add> and <rem> tags -#[derive(Serialize, Deserialize, Debug)] -pub struct HostAddRemove { - /// The IP addresses to be added to or removed from the host - #[serde(rename = "host:addr", alias = "addr")] - pub addresses: Option>, - /// The statuses to be added to or removed from the host - #[serde(rename = "host:status", alias = "status")] - pub statuses: Option>, -} - -/// Type for data under the host <update> tag -#[derive(Serialize, Deserialize, Debug)] -pub struct HostUpdateData { - /// XML namespace for host commands - #[serde(rename = "xmlns:host", alias = "xmlns")] - xmlns: String, - /// The name of the host - #[serde(rename = "host:name", alias = "name")] - name: StringValue, - /// The IP addresses and statuses to be added to the host - #[serde(rename = "host:add", alias = "add")] - add: Option, - /// The IP addresses and statuses to be removed from the host - #[serde(rename = "host:rem", alias = "rem")] - remove: Option, - /// The host details that need to be updated - #[serde(rename = "host:chg", alias = "chg")] - change_info: Option, -} - -#[derive(Serialize, Deserialize, Debug, ElementName)] -#[element_name(name = "update")] -/// Type for EPP XML <update> command for hosts -pub struct HostUpdate { - /// The instance holding the data for the host to be updated - #[serde(rename = "host:update", alias = "update")] - host: HostUpdateData, -} +pub type EppHostUpdate = EppObject>; impl EppHostUpdate { /// Creates a new EppObject for host update corresponding to the <epp> tag in EPP XML pub fn new(name: &str, client_tr_id: &str) -> EppHostUpdate { - EppObject::build(Command::::new( - HostUpdate { - host: HostUpdateData { + EppObject::build(Command::::new( + HostUpdateRequest { + host: HostUpdateRequestData { xmlns: EPP_HOST_XMLNS.to_string(), name: name.into(), add: None, @@ -158,3 +111,54 @@ impl EppHostUpdate { self.data.command.host.remove = Some(remove); } } + +/// Type that represents the <epp> tag for the EPP XML host update response +pub type EppHostUpdateResponse = EppCommandResponse; + +/// Type for data under the <chg> tag +#[derive(Serialize, Deserialize, Debug)] +pub struct HostChangeInfo { + /// The new name for the host + #[serde(rename = "host:name", alias = "name")] + pub name: StringValue, +} + +/// Type for data under the <add> and <rem> tags +#[derive(Serialize, Deserialize, Debug)] +pub struct HostAddRemove { + /// The IP addresses to be added to or removed from the host + #[serde(rename = "host:addr", alias = "addr")] + pub addresses: Option>, + /// The statuses to be added to or removed from the host + #[serde(rename = "host:status", alias = "status")] + pub statuses: Option>, +} + +/// Type for data under the host <update> tag +#[derive(Serialize, Deserialize, Debug)] +pub struct HostUpdateRequestData { + /// XML namespace for host commands + #[serde(rename = "xmlns:host", alias = "xmlns")] + xmlns: String, + /// The name of the host + #[serde(rename = "host:name", alias = "name")] + name: StringValue, + /// The IP addresses and statuses to be added to the host + #[serde(rename = "host:add", alias = "add")] + add: Option, + /// The IP addresses and statuses to be removed from the host + #[serde(rename = "host:rem", alias = "rem")] + remove: Option, + /// The host details that need to be updated + #[serde(rename = "host:chg", alias = "chg")] + change_info: Option, +} + +#[derive(Serialize, Deserialize, Debug, ElementName)] +#[element_name(name = "update")] +/// Type for EPP XML <update> command for hosts +pub struct HostUpdateRequest { + /// The instance holding the data for the host to be updated + #[serde(rename = "host:update", alias = "update")] + host: HostUpdateRequestData, +} diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 91e6cac..1db3835 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -31,6 +31,7 @@ mod response { use crate::host::create::EppHostCreateResponse; use crate::host::delete::EppHostDeleteResponse; use crate::host::info::EppHostInfoResponse; + use crate::host::update::EppHostUpdateResponse; 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 cd7a094..ade3955 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -34,6 +34,9 @@ mod request { use crate::host::create::EppHostCreate; use crate::host::delete::EppHostDelete; use crate::host::info::EppHostInfo; + use crate::host::update::EppHostUpdate; + use crate::host::update::HostAddRemove; + use crate::host::update::HostChangeInfo; use chrono::{DateTime, NaiveDate}; use std::str::FromStr;