Refactor host info models
This commit is contained in:
parent
fc21db3cac
commit
b8f9eb1f8f
|
@ -5,12 +5,10 @@ pub mod request;
|
|||
pub mod response;
|
||||
pub mod xml;
|
||||
|
||||
pub use request::host::info::*;
|
||||
pub use request::host::update::*;
|
||||
pub use request::message::ack::*;
|
||||
pub use request::message::poll::*;
|
||||
|
||||
pub use response::host::info::*;
|
||||
pub use response::host::update::*;
|
||||
pub use response::message::ack::*;
|
||||
pub use response::message::poll::*;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//! Types for EPP host requests
|
||||
|
||||
pub mod info;
|
||||
pub mod update;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//! Types for EPP host responses
|
||||
|
||||
pub mod info;
|
||||
pub mod update;
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
//! Types for EPP host info response
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::epp::object::data::{HostAddr, HostStatus};
|
||||
use crate::epp::object::{EppObject, StringValue};
|
||||
use crate::epp::response::CommandResponse;
|
||||
|
||||
/// Type that represents the <epp> tag for the EPP XML host info response
|
||||
pub type EppHostInfoResponse = EppObject<CommandResponse<HostInfoResult>>;
|
||||
|
||||
/// Type that represents the <infData> tag for host info response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostInfoData {
|
||||
/// XML namespace for host response data
|
||||
#[serde(rename = "xmlns:host")]
|
||||
xmlns: String,
|
||||
/// The host name
|
||||
pub name: StringValue,
|
||||
/// The host ROID
|
||||
pub roid: StringValue,
|
||||
/// The list of host statuses
|
||||
#[serde(rename = "status")]
|
||||
pub statuses: Vec<HostStatus>,
|
||||
/// The list of host IP addresses
|
||||
#[serde(rename = "addr")]
|
||||
pub addresses: Vec<HostAddr>,
|
||||
/// The epp user to whom the host belongs
|
||||
#[serde(rename = "clID")]
|
||||
pub client_id: StringValue,
|
||||
/// THe epp user that created the host
|
||||
#[serde(rename = "crID")]
|
||||
pub creator_id: StringValue,
|
||||
/// The host creation date
|
||||
#[serde(rename = "crDate")]
|
||||
pub created_at: StringValue,
|
||||
/// The epp user that last updated the host
|
||||
#[serde(rename = "upID")]
|
||||
pub updater_id: Option<StringValue>,
|
||||
/// The host last update date
|
||||
#[serde(rename = "upDate")]
|
||||
pub updated_at: Option<StringValue>,
|
||||
/// The host transfer date
|
||||
#[serde(rename = "trDate")]
|
||||
pub transferred_at: Option<StringValue>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for host info response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostInfoResult {
|
||||
/// Data under the <infData> tag
|
||||
#[serde(rename = "infData")]
|
||||
pub info_data: HostInfoData,
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
pub mod check;
|
||||
pub mod create;
|
||||
pub mod delete;
|
||||
pub mod info;
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
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::CommandResponse;
|
||||
use crate::epp::xml::EPP_HOST_XMLNS;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -16,7 +18,7 @@ use serde::{Deserialize, Serialize};
|
|||
///
|
||||
/// use epp_client::config::{EppClientConfig, EppClientConnection};
|
||||
/// use epp_client::EppClient;
|
||||
/// use epp_client::epp::{EppHostInfo, EppHostInfoResponse};
|
||||
/// use epp_client::host::info::{EppHostInfo, EppHostInfoResponse};
|
||||
/// use epp_client::epp::generate_client_tr_id;
|
||||
///
|
||||
/// #[tokio::main]
|
||||
|
@ -53,11 +55,31 @@ use serde::{Deserialize, Serialize};
|
|||
/// client.logout().await.unwrap();
|
||||
/// }
|
||||
/// ```
|
||||
pub type EppHostInfo = EppObject<Command<HostInfo>>;
|
||||
pub type EppHostInfo = EppObject<Command<HostInfoRequest>>;
|
||||
|
||||
impl EppHostInfo {
|
||||
/// Creates a new EppObject for host info corresponding to the <epp> tag in EPP XML
|
||||
pub fn new(name: &str, client_tr_id: &str) -> EppHostInfo {
|
||||
EppObject::build(Command::<HostInfoRequest>::new(
|
||||
HostInfoRequest {
|
||||
info: HostInfoRequestData {
|
||||
xmlns: EPP_HOST_XMLNS.to_string(),
|
||||
name: name.into(),
|
||||
},
|
||||
},
|
||||
client_tr_id,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Type that represents the <epp> tag for the EPP XML host info response
|
||||
pub type EppHostInfoResponse = EppObject<CommandResponse<HostInfoResponse>>;
|
||||
|
||||
// Request
|
||||
|
||||
/// Type for data under the host <info> tag
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostInfoData {
|
||||
pub struct HostInfoRequestData {
|
||||
/// XML namespace for host commands
|
||||
#[serde(rename = "xmlns:host", alias = "xmlns")]
|
||||
xmlns: String,
|
||||
|
@ -69,23 +91,54 @@ pub struct HostInfoData {
|
|||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||
#[element_name(name = "info")]
|
||||
/// Type for EPP XML <info> command for hosts
|
||||
pub struct HostInfo {
|
||||
pub struct HostInfoRequest {
|
||||
/// The instance holding the data for the host query
|
||||
#[serde(rename = "host:info", alias = "info")]
|
||||
info: HostInfoData,
|
||||
info: HostInfoRequestData,
|
||||
}
|
||||
|
||||
impl EppHostInfo {
|
||||
/// Creates a new EppObject for host info corresponding to the <epp> tag in EPP XML
|
||||
pub fn new(name: &str, client_tr_id: &str) -> EppHostInfo {
|
||||
EppObject::build(Command::<HostInfo>::new(
|
||||
HostInfo {
|
||||
info: HostInfoData {
|
||||
xmlns: EPP_HOST_XMLNS.to_string(),
|
||||
name: name.into(),
|
||||
},
|
||||
},
|
||||
client_tr_id,
|
||||
))
|
||||
}
|
||||
// Response
|
||||
|
||||
/// Type that represents the <infData> tag for host info response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostInfoResponseData {
|
||||
/// XML namespace for host response data
|
||||
#[serde(rename = "xmlns:host")]
|
||||
xmlns: String,
|
||||
/// The host name
|
||||
pub name: StringValue,
|
||||
/// The host ROID
|
||||
pub roid: StringValue,
|
||||
/// The list of host statuses
|
||||
#[serde(rename = "status")]
|
||||
pub statuses: Vec<HostStatus>,
|
||||
/// The list of host IP addresses
|
||||
#[serde(rename = "addr")]
|
||||
pub addresses: Vec<HostAddr>,
|
||||
/// The epp user to whom the host belongs
|
||||
#[serde(rename = "clID")]
|
||||
pub client_id: StringValue,
|
||||
/// THe epp user that created the host
|
||||
#[serde(rename = "crID")]
|
||||
pub creator_id: StringValue,
|
||||
/// The host creation date
|
||||
#[serde(rename = "crDate")]
|
||||
pub created_at: StringValue,
|
||||
/// The epp user that last updated the host
|
||||
#[serde(rename = "upID")]
|
||||
pub updater_id: Option<StringValue>,
|
||||
/// The host last update date
|
||||
#[serde(rename = "upDate")]
|
||||
pub updated_at: Option<StringValue>,
|
||||
/// The host transfer date
|
||||
#[serde(rename = "trDate")]
|
||||
pub transferred_at: Option<StringValue>,
|
||||
}
|
||||
|
||||
/// Type that represents the <resData> tag for host info response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostInfoResponse {
|
||||
/// Data under the <infData> tag
|
||||
#[serde(rename = "infData")]
|
||||
pub info_data: HostInfoResponseData,
|
||||
}
|
|
@ -30,6 +30,7 @@ mod response {
|
|||
use crate::host::check::EppHostCheckResponse;
|
||||
use crate::host::create::EppHostCreateResponse;
|
||||
use crate::host::delete::EppHostDeleteResponse;
|
||||
use crate::host::info::EppHostInfoResponse;
|
||||
|
||||
const SVTRID: &str = "RO-6879-1627224678242975";
|
||||
const SUCCESS_MSG: &str = "Command completed successfully";
|
||||
|
|
|
@ -33,6 +33,7 @@ mod request {
|
|||
use crate::host::check::EppHostCheck;
|
||||
use crate::host::create::EppHostCreate;
|
||||
use crate::host::delete::EppHostDelete;
|
||||
use crate::host::info::EppHostInfo;
|
||||
use chrono::{DateTime, NaiveDate};
|
||||
use std::str::FromStr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue