Refactor domain update models
This commit is contained in:
parent
c5dfdd85b6
commit
3f3502fea2
|
@ -4,3 +4,4 @@ pub mod delete;
|
|||
pub mod info;
|
||||
pub mod renew;
|
||||
pub mod transfer;
|
||||
pub mod update;
|
||||
|
|
|
@ -5,6 +5,7 @@ use epp_client_macros::*;
|
|||
use crate::epp::object::data::{DomainAuthInfo, DomainContact, DomainStatus, HostList};
|
||||
use crate::epp::object::{ElementName, EppObject, StringValue};
|
||||
use crate::epp::request::Command;
|
||||
use crate::epp::response::EppCommandResponse;
|
||||
use crate::epp::xml::EPP_DOMAIN_XMLNS;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -19,7 +20,7 @@ use serde::{Deserialize, Serialize};
|
|||
/// use epp_client::config::{EppClientConfig, EppClientConnection};
|
||||
/// use epp_client::EppClient;
|
||||
/// use epp_client::epp::object::data::{DomainStatus, DomainContact};
|
||||
/// use epp_client::epp::{EppDomainUpdate, EppDomainUpdateResponse, DomainAddRemove};
|
||||
/// use epp_client::domain::update::{EppDomainUpdate, EppDomainUpdateResponse, DomainAddRemove};
|
||||
/// use epp_client::epp::generate_client_tr_id;
|
||||
///
|
||||
/// #[tokio::main]
|
||||
|
@ -80,7 +81,44 @@ use serde::{Deserialize, Serialize};
|
|||
/// client.logout().await.unwrap();
|
||||
/// }
|
||||
/// ```
|
||||
pub type EppDomainUpdate = EppObject<Command<DomainUpdate>>;
|
||||
pub type EppDomainUpdate = EppObject<Command<DomainUpdateRequest>>;
|
||||
|
||||
impl EppDomainUpdate {
|
||||
/// Creates a new EppObject for domain update corresponding to the <epp> tag in EPP XML
|
||||
/// with the <ns> tag containing <hostObj> tags
|
||||
pub fn new(name: &str, client_tr_id: &str) -> EppDomainUpdate {
|
||||
EppObject::build(Command::<DomainUpdateRequest>::new(
|
||||
DomainUpdateRequest {
|
||||
domain: DomainUpdateRequestData {
|
||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||
name: name.into(),
|
||||
add: None,
|
||||
remove: None,
|
||||
change_info: None,
|
||||
},
|
||||
},
|
||||
client_tr_id,
|
||||
))
|
||||
}
|
||||
|
||||
/// Sets the data for the <chg> tag
|
||||
pub fn info(&mut self, info: DomainChangeInfo) {
|
||||
self.data.command.domain.change_info = Some(info);
|
||||
}
|
||||
|
||||
/// Sets the data for the <add> tag
|
||||
pub fn add(&mut self, add: DomainAddRemove) {
|
||||
self.data.command.domain.add = Some(add);
|
||||
}
|
||||
|
||||
/// Sets the data for the <rem> tag
|
||||
pub fn remove(&mut self, remove: DomainAddRemove) {
|
||||
self.data.command.domain.remove = Some(remove);
|
||||
}
|
||||
}
|
||||
|
||||
/// Type that represents the <epp> tag for the EPP XML domain update response
|
||||
pub type EppDomainUpdateResponse = EppCommandResponse;
|
||||
|
||||
/// Type for elements under the <chg> tag for domain update
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
@ -110,7 +148,7 @@ pub struct DomainAddRemove {
|
|||
|
||||
/// Type for elements under the <update> tag for domain update
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct DomainUpdateData {
|
||||
pub struct DomainUpdateRequestData {
|
||||
/// XML namespace for domain commands
|
||||
#[serde(rename = "xmlns:domain", alias = "xmlns")]
|
||||
pub xmlns: String,
|
||||
|
@ -133,41 +171,7 @@ pub struct DomainUpdateData {
|
|||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||
#[element_name(name = "update")]
|
||||
/// Type for EPP XML <update> command for domains
|
||||
pub struct DomainUpdate {
|
||||
pub struct DomainUpdateRequest {
|
||||
#[serde(rename = "domain:update", alias = "update")]
|
||||
pub domain: DomainUpdateData,
|
||||
}
|
||||
|
||||
impl EppDomainUpdate {
|
||||
/// Creates a new EppObject for domain update corresponding to the <epp> tag in EPP XML
|
||||
/// with the <ns> tag containing <hostObj> tags
|
||||
pub fn new(name: &str, client_tr_id: &str) -> EppDomainUpdate {
|
||||
EppObject::build(Command::<DomainUpdate>::new(
|
||||
DomainUpdate {
|
||||
domain: DomainUpdateData {
|
||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||
name: name.into(),
|
||||
add: None,
|
||||
remove: None,
|
||||
change_info: None,
|
||||
},
|
||||
},
|
||||
client_tr_id,
|
||||
))
|
||||
}
|
||||
|
||||
/// Sets the data for the <chg> tag
|
||||
pub fn info(&mut self, info: DomainChangeInfo) {
|
||||
self.data.command.domain.change_info = Some(info);
|
||||
}
|
||||
|
||||
/// Sets the data for the <add> tag
|
||||
pub fn add(&mut self, add: DomainAddRemove) {
|
||||
self.data.command.domain.add = Some(add);
|
||||
}
|
||||
|
||||
/// Sets the data for the <rem> tag
|
||||
pub fn remove(&mut self, remove: DomainAddRemove) {
|
||||
self.data.command.domain.remove = Some(remove);
|
||||
}
|
||||
pub domain: DomainUpdateRequestData,
|
||||
}
|
|
@ -12,7 +12,6 @@ pub use request::contact::info::*;
|
|||
pub use request::contact::update::*;
|
||||
pub use request::domain::rgp::report::*;
|
||||
pub use request::domain::rgp::request::*;
|
||||
pub use request::domain::update::*;
|
||||
pub use request::host::check::*;
|
||||
pub use request::host::create::*;
|
||||
pub use request::host::delete::*;
|
||||
|
@ -28,7 +27,6 @@ pub use response::contact::info::*;
|
|||
pub use response::contact::update::*;
|
||||
pub use response::domain::rgp::report::*;
|
||||
pub use response::domain::rgp::request::*;
|
||||
pub use response::domain::update::*;
|
||||
pub use response::host::check::*;
|
||||
pub use response::host::create::*;
|
||||
pub use response::host::delete::*;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//! Types for EPP domain requests
|
||||
|
||||
pub mod rgp;
|
||||
pub mod update;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use epp_client_macros::*;
|
||||
|
||||
use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData};
|
||||
use crate::epp::object::{ElementName, EppObject, StringValue};
|
||||
use crate::epp::request::domain::update::{DomainChangeInfo, DomainUpdate, DomainUpdateData};
|
||||
use crate::epp::request::{CommandWithExtension, Extension};
|
||||
use crate::epp::xml::{EPP_DOMAIN_RGP_EXT_XMLNS, EPP_DOMAIN_XMLNS};
|
||||
use chrono::{DateTime, SecondsFormat, Utc};
|
||||
|
@ -81,7 +81,7 @@ use serde::{Deserialize, Serialize};
|
|||
/// }
|
||||
/// ```
|
||||
pub type EppDomainRgpRestoreReport =
|
||||
EppObject<CommandWithExtension<DomainUpdate, RgpRestoreReport>>;
|
||||
EppObject<CommandWithExtension<DomainUpdateRequest, RgpRestoreReport>>;
|
||||
|
||||
/// Type corresponding to the <report> section in the EPP rgp restore extension
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
@ -147,9 +147,9 @@ impl EppDomainRgpRestoreReport {
|
|||
) -> EppDomainRgpRestoreReport {
|
||||
let statements = statements.iter().map(|&s| s.into()).collect();
|
||||
|
||||
let command = CommandWithExtension::<DomainUpdate, RgpRestoreReport> {
|
||||
command: DomainUpdate {
|
||||
domain: DomainUpdateData {
|
||||
let command = CommandWithExtension::<DomainUpdateRequest, RgpRestoreReport> {
|
||||
command: DomainUpdateRequest {
|
||||
domain: DomainUpdateRequestData {
|
||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||
name: name.into(),
|
||||
add: None,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use epp_client_macros::*;
|
||||
|
||||
use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData};
|
||||
use crate::epp::object::{ElementName, EppObject};
|
||||
use crate::epp::request::domain::update::{DomainChangeInfo, DomainUpdate, DomainUpdateData};
|
||||
use crate::epp::request::{CommandWithExtension, Extension};
|
||||
use crate::epp::xml::{EPP_DOMAIN_RGP_EXT_XMLNS, EPP_DOMAIN_XMLNS};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -58,7 +58,7 @@ use serde::{Deserialize, Serialize};
|
|||
/// }
|
||||
/// ```
|
||||
pub type EppDomainRgpRestoreRequest =
|
||||
EppObject<CommandWithExtension<DomainUpdate, RgpRestoreRequest>>;
|
||||
EppObject<CommandWithExtension<DomainUpdateRequest, RgpRestoreRequest>>;
|
||||
|
||||
/// Type corresponding to the <restore> tag for an rgp restore request
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
@ -82,9 +82,9 @@ pub struct RgpRestoreRequest {
|
|||
impl EppDomainRgpRestoreRequest {
|
||||
/// Creates a new EppObject for domain rgp restore request corresponding to the <epp> tag in EPP XML
|
||||
pub fn new(name: &str, client_tr_id: &str) -> EppDomainRgpRestoreRequest {
|
||||
let command = CommandWithExtension::<DomainUpdate, RgpRestoreRequest> {
|
||||
command: DomainUpdate {
|
||||
domain: DomainUpdateData {
|
||||
let command = CommandWithExtension::<DomainUpdateRequest, RgpRestoreRequest> {
|
||||
command: DomainUpdateRequest {
|
||||
domain: DomainUpdateRequestData {
|
||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||
name: name.into(),
|
||||
add: None,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//! Types for EPP domain responses
|
||||
|
||||
pub mod rgp;
|
||||
pub mod update;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
//! Types for EPP domain update response
|
||||
|
||||
use crate::epp::response::EppCommandResponse;
|
||||
|
||||
/// Type that represents the <epp> tag for the EPP XML domain update response
|
||||
pub type EppDomainUpdateResponse = EppCommandResponse;
|
|
@ -13,6 +13,7 @@ mod response {
|
|||
use crate::domain::transfer::EppDomainTransferQueryResponse;
|
||||
use crate::domain::transfer::EppDomainTransferRejectResponse;
|
||||
use crate::domain::transfer::EppDomainTransferRequestResponse;
|
||||
use crate::domain::update::EppDomainUpdateResponse;
|
||||
use crate::epp::response::ExpiryType;
|
||||
use crate::epp::response::Relative;
|
||||
use crate::epp::response::{
|
||||
|
|
|
@ -13,6 +13,9 @@ mod request {
|
|||
use crate::domain::transfer::EppDomainTransferQuery;
|
||||
use crate::domain::transfer::EppDomainTransferReject;
|
||||
use crate::domain::transfer::EppDomainTransferRequest;
|
||||
use crate::domain::update::DomainAddRemove;
|
||||
use crate::domain::update::DomainChangeInfo;
|
||||
use crate::domain::update::EppDomainUpdate;
|
||||
use crate::epp::object::data::{
|
||||
Address, ContactStatus, DomainAuthInfo, DomainContact, DomainStatus, HostAddr, HostAttr,
|
||||
HostStatus, Phone, PostalInfo,
|
||||
|
|
Loading…
Reference in New Issue