Refactor host info models
This commit is contained in:
parent
b8f9eb1f8f
commit
388f153763
|
@ -5,11 +5,9 @@ pub mod request;
|
||||||
pub mod response;
|
pub mod response;
|
||||||
pub mod xml;
|
pub mod xml;
|
||||||
|
|
||||||
pub use request::host::update::*;
|
|
||||||
pub use request::message::ack::*;
|
pub use request::message::ack::*;
|
||||||
pub use request::message::poll::*;
|
pub use request::message::poll::*;
|
||||||
|
|
||||||
pub use response::host::update::*;
|
|
||||||
pub use response::message::ack::*;
|
pub use response::message::ack::*;
|
||||||
pub use response::message::poll::*;
|
pub use response::message::poll::*;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//! Types for EPP requests
|
//! Types for EPP requests
|
||||||
|
|
||||||
pub mod host;
|
|
||||||
pub mod message;
|
pub mod message;
|
||||||
|
|
||||||
use serde::{ser::SerializeStruct, ser::Serializer, Deserialize, Serialize};
|
use serde::{ser::SerializeStruct, ser::Serializer, Deserialize, Serialize};
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
//! Types for EPP host requests
|
|
||||||
|
|
||||||
pub mod update;
|
|
|
@ -1,6 +1,5 @@
|
||||||
//! Types for EPP responses
|
//! Types for EPP responses
|
||||||
|
|
||||||
pub mod host;
|
|
||||||
pub mod message;
|
pub mod message;
|
||||||
|
|
||||||
use epp_client_macros::*;
|
use epp_client_macros::*;
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
//! Types for EPP host responses
|
|
||||||
|
|
||||||
pub mod update;
|
|
|
@ -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;
|
|
|
@ -2,3 +2,4 @@ pub mod check;
|
||||||
pub mod create;
|
pub mod create;
|
||||||
pub mod delete;
|
pub mod delete;
|
||||||
pub mod info;
|
pub mod info;
|
||||||
|
pub mod update;
|
||||||
|
|
|
@ -5,6 +5,7 @@ use epp_client_macros::*;
|
||||||
use crate::epp::object::data::{HostAddr, HostStatus};
|
use crate::epp::object::data::{HostAddr, HostStatus};
|
||||||
use crate::epp::object::{ElementName, EppObject, StringValue};
|
use crate::epp::object::{ElementName, EppObject, StringValue};
|
||||||
use crate::epp::request::Command;
|
use crate::epp::request::Command;
|
||||||
|
use crate::epp::response::EppCommandResponse;
|
||||||
use crate::epp::xml::EPP_HOST_XMLNS;
|
use crate::epp::xml::EPP_HOST_XMLNS;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ use serde::{Deserialize, Serialize};
|
||||||
/// use epp_client::config::{EppClientConfig, EppClientConnection};
|
/// use epp_client::config::{EppClientConfig, EppClientConnection};
|
||||||
/// use epp_client::EppClient;
|
/// use epp_client::EppClient;
|
||||||
/// use epp_client::epp::object::data::{HostAddr, HostStatus};
|
/// 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;
|
/// use epp_client::epp::generate_client_tr_id;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
|
@ -76,62 +77,14 @@ use serde::{Deserialize, Serialize};
|
||||||
/// client.logout().await.unwrap();
|
/// client.logout().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppHostUpdate = EppObject<Command<HostUpdate>>;
|
pub type EppHostUpdate = EppObject<Command<HostUpdateRequest>>;
|
||||||
|
|
||||||
/// 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<Vec<HostAddr>>,
|
|
||||||
/// The statuses to be added to or removed from the host
|
|
||||||
#[serde(rename = "host:status", alias = "status")]
|
|
||||||
pub statuses: Option<Vec<HostStatus>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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<HostAddRemove>,
|
|
||||||
/// The IP addresses and statuses to be removed from the host
|
|
||||||
#[serde(rename = "host:rem", alias = "rem")]
|
|
||||||
remove: Option<HostAddRemove>,
|
|
||||||
/// The host details that need to be updated
|
|
||||||
#[serde(rename = "host:chg", alias = "chg")]
|
|
||||||
change_info: Option<HostChangeInfo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[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,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EppHostUpdate {
|
impl EppHostUpdate {
|
||||||
/// Creates a new EppObject for host update corresponding to the <epp> tag in EPP XML
|
/// 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 {
|
pub fn new(name: &str, client_tr_id: &str) -> EppHostUpdate {
|
||||||
EppObject::build(Command::<HostUpdate>::new(
|
EppObject::build(Command::<HostUpdateRequest>::new(
|
||||||
HostUpdate {
|
HostUpdateRequest {
|
||||||
host: HostUpdateData {
|
host: HostUpdateRequestData {
|
||||||
xmlns: EPP_HOST_XMLNS.to_string(),
|
xmlns: EPP_HOST_XMLNS.to_string(),
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
add: None,
|
add: None,
|
||||||
|
@ -158,3 +111,54 @@ impl EppHostUpdate {
|
||||||
self.data.command.host.remove = Some(remove);
|
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<Vec<HostAddr>>,
|
||||||
|
/// The statuses to be added to or removed from the host
|
||||||
|
#[serde(rename = "host:status", alias = "status")]
|
||||||
|
pub statuses: Option<Vec<HostStatus>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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<HostAddRemove>,
|
||||||
|
/// The IP addresses and statuses to be removed from the host
|
||||||
|
#[serde(rename = "host:rem", alias = "rem")]
|
||||||
|
remove: Option<HostAddRemove>,
|
||||||
|
/// The host details that need to be updated
|
||||||
|
#[serde(rename = "host:chg", alias = "chg")]
|
||||||
|
change_info: Option<HostChangeInfo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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,
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ mod response {
|
||||||
use crate::host::create::EppHostCreateResponse;
|
use crate::host::create::EppHostCreateResponse;
|
||||||
use crate::host::delete::EppHostDeleteResponse;
|
use crate::host::delete::EppHostDeleteResponse;
|
||||||
use crate::host::info::EppHostInfoResponse;
|
use crate::host::info::EppHostInfoResponse;
|
||||||
|
use crate::host::update::EppHostUpdateResponse;
|
||||||
|
|
||||||
const SVTRID: &str = "RO-6879-1627224678242975";
|
const SVTRID: &str = "RO-6879-1627224678242975";
|
||||||
const SUCCESS_MSG: &str = "Command completed successfully";
|
const SUCCESS_MSG: &str = "Command completed successfully";
|
||||||
|
|
|
@ -34,6 +34,9 @@ mod request {
|
||||||
use crate::host::create::EppHostCreate;
|
use crate::host::create::EppHostCreate;
|
||||||
use crate::host::delete::EppHostDelete;
|
use crate::host::delete::EppHostDelete;
|
||||||
use crate::host::info::EppHostInfo;
|
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 chrono::{DateTime, NaiveDate};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue