|
|
|
@ -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<Command<HostUpdate>>;
|
|
|
|
|
|
|
|
|
|
/// 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,
|
|
|
|
|
}
|
|
|
|
|
pub type EppHostUpdate = EppObject<Command<HostUpdateRequest>>;
|
|
|
|
|
|
|
|
|
|
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::<HostUpdate>::new(
|
|
|
|
|
HostUpdate {
|
|
|
|
|
host: HostUpdateData {
|
|
|
|
|
EppObject::build(Command::<HostUpdateRequest>::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<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,
|
|
|
|
|
}
|