Refactor rgp request models

This commit is contained in:
Nicholas Rempel 2021-11-26 10:02:07 -08:00 committed by masalachai
parent c198a7345b
commit dc90f91b8f
13 changed files with 56 additions and 69 deletions

View File

@ -2,12 +2,12 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::domain::rgp::request::RgpRequestResponse;
use crate::epp::object::data::{DomainAuthInfo, DomainContact, DomainStatus, HostAttr}; use crate::epp::object::data::{DomainAuthInfo, DomainContact, DomainStatus, HostAttr};
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::CommandResponseWithExtension; use crate::epp::response::CommandResponseWithExtension;
use crate::epp::xml::EPP_DOMAIN_XMLNS; use crate::epp::xml::EPP_DOMAIN_XMLNS;
use crate::epp::RgpRequestResult;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// Type that represents the <epp> request for domain <info> command /// Type that represents the <epp> request for domain <info> command
@ -78,7 +78,7 @@ impl EppDomainInfo {
/// Type that represents the <epp> tag for the EPP XML domain info response /// Type that represents the <epp> tag for the EPP XML domain info response
pub type EppDomainInfoResponse = pub type EppDomainInfoResponse =
EppObject<CommandResponseWithExtension<DomainInfoResponse, RgpRequestResult>>; EppObject<CommandResponseWithExtension<DomainInfoResponse, RgpRequestResponse>>;
// Request // Request

View File

@ -1,3 +1,4 @@
//! Types for EPP RGP restore requests //! Types for EPP RGP restore requests
pub mod report; pub mod report;
pub mod request;

View File

@ -3,8 +3,9 @@
use epp_client_macros::*; use epp_client_macros::*;
use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData}; use crate::domain::update::{DomainChangeInfo, DomainUpdateRequest, DomainUpdateRequestData};
use crate::epp::object::{ElementName, EppObject}; use crate::epp::object::{ElementName, EmptyTag, EppObject, Extension};
use crate::epp::request::{CommandWithExtension, Extension}; use crate::epp::request::CommandWithExtension;
use crate::epp::response::CommandResponseWithExtension;
use crate::epp::xml::{EPP_DOMAIN_RGP_EXT_XMLNS, EPP_DOMAIN_XMLNS}; use crate::epp::xml::{EPP_DOMAIN_RGP_EXT_XMLNS, EPP_DOMAIN_XMLNS};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -17,7 +18,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::{EppDomainRgpRestoreRequest, EppDomainRgpRestoreRequestResponse}; /// use epp_client::domain::rgp::request::{EppDomainRgpRestoreRequest, EppDomainRgpRestoreRequestResponse};
/// use epp_client::epp::generate_client_tr_id; /// use epp_client::epp::generate_client_tr_id;
/// ///
/// #[tokio::main] /// #[tokio::main]
@ -60,25 +61,6 @@ use serde::{Deserialize, Serialize};
pub type EppDomainRgpRestoreRequest = pub type EppDomainRgpRestoreRequest =
EppObject<CommandWithExtension<DomainUpdateRequest, RgpRestoreRequest>>; EppObject<CommandWithExtension<DomainUpdateRequest, RgpRestoreRequest>>;
/// Type corresponding to the &lt;restore&gt; tag for an rgp restore request
#[derive(Serialize, Deserialize, Debug)]
pub struct RgpRestoreRequestData {
/// The value of the op attribute in the &lt;restore&gt; tag
pub op: String,
}
#[derive(Serialize, Deserialize, Debug, ElementName)]
#[element_name(name = "rgp:update")]
/// Type for EPP XML &lt;check&gt; command for domains
pub struct RgpRestoreRequest {
/// XML namespace for the RGP restore extension
#[serde(rename = "xmlns:rgp", alias = "xmlns")]
xmlns: String,
/// The object holding the list of domains to be checked
#[serde(rename = "rgp:restore", alias = "restore")]
restore: RgpRestoreRequestData,
}
impl EppDomainRgpRestoreRequest { impl EppDomainRgpRestoreRequest {
/// Creates a new EppObject for domain rgp restore request corresponding to the &lt;epp&gt; tag in EPP XML /// Creates a new EppObject for domain rgp restore request corresponding to the &lt;epp&gt; tag in EPP XML
pub fn new(name: &str, client_tr_id: &str) -> EppDomainRgpRestoreRequest { pub fn new(name: &str, client_tr_id: &str) -> EppDomainRgpRestoreRequest {
@ -109,3 +91,50 @@ impl EppDomainRgpRestoreRequest {
EppObject::build(command) EppObject::build(command)
} }
} }
/// Type that represents the &lt;epp&gt; tag for the EPP XML rgp restore request response
pub type EppDomainRgpRestoreRequestResponse =
EppObject<CommandResponseWithExtension<EmptyTag, RgpRequestResponse>>;
// Request
/// Type corresponding to the &lt;restore&gt; tag for an rgp restore request
#[derive(Serialize, Deserialize, Debug)]
pub struct RgpRestoreRequestData {
/// The value of the op attribute in the &lt;restore&gt; tag
pub op: String,
}
#[derive(Serialize, Deserialize, Debug, ElementName)]
#[element_name(name = "rgp:update")]
/// Type for EPP XML &lt;check&gt; command for domains
pub struct RgpRestoreRequest {
/// XML namespace for the RGP restore extension
#[serde(rename = "xmlns:rgp", alias = "xmlns")]
xmlns: String,
/// The object holding the list of domains to be checked
#[serde(rename = "rgp:restore", alias = "restore")]
restore: RgpRestoreRequestData,
}
// Response
/// Type that represents the &lt;rgpStatus&gt; tag for domain rgp restore request response
#[derive(Serialize, Deserialize, Debug)]
pub struct RgpStatus {
/// The domain RGP status
#[serde(rename = "s")]
pub status: String,
}
#[derive(Serialize, Deserialize, Debug, ElementName)]
#[serde(rename = "upData")]
#[element_name(name = "upData")]
/// Type that represents the &lt;resData&gt; tag for domain transfer response
pub struct RgpRequestResponse {
#[serde(rename = "xmlns:rgp")]
xmlns: String,
/// Data under the &lt;rgpStatus&gt; tag
#[serde(rename = "rgpStatus")]
pub rgp_status: RgpStatus,
}

View File

@ -10,7 +10,6 @@ pub use request::contact::create::*;
pub use request::contact::delete::*; pub use request::contact::delete::*;
pub use request::contact::info::*; pub use request::contact::info::*;
pub use request::contact::update::*; pub use request::contact::update::*;
pub use request::domain::rgp::request::*;
pub use request::host::check::*; pub use request::host::check::*;
pub use request::host::create::*; pub use request::host::create::*;
pub use request::host::delete::*; pub use request::host::delete::*;
@ -24,7 +23,6 @@ pub use response::contact::create::*;
pub use response::contact::delete::*; pub use response::contact::delete::*;
pub use response::contact::info::*; pub use response::contact::info::*;
pub use response::contact::update::*; pub use response::contact::update::*;
pub use response::domain::rgp::request::*;
pub use response::host::check::*; pub use response::host::check::*;
pub use response::host::create::*; pub use response::host::create::*;
pub use response::host::delete::*; pub use response::host::delete::*;

View File

@ -1,7 +1,6 @@
//! Types for EPP requests //! Types for EPP requests
pub mod contact; pub mod contact;
pub mod domain;
pub mod host; pub mod host;
pub mod message; pub mod message;

View File

@ -1,3 +0,0 @@
//! Types for EPP domain requests
pub mod rgp;

View File

@ -1,3 +0,0 @@
//! Types for EPP RGP restore requests
pub mod request;

View File

@ -1,7 +1,6 @@
//! Types for EPP responses //! Types for EPP responses
pub mod contact; pub mod contact;
pub mod domain;
pub mod host; pub mod host;
pub mod message; pub mod message;

View File

@ -1,3 +0,0 @@
//! Types for EPP domain responses
pub mod rgp;

View File

@ -1,3 +0,0 @@
//! Types for RGP restore responses
pub mod request;

View File

@ -1,29 +0,0 @@
use epp_client_macros::*;
use crate::epp::object::{ElementName, EmptyTag, EppObject};
use crate::epp::response::CommandResponseWithExtension;
use serde::{Deserialize, Serialize};
/// Type that represents the &lt;epp&gt; tag for the EPP XML rgp restore request response
pub type EppDomainRgpRestoreRequestResponse =
EppObject<CommandResponseWithExtension<EmptyTag, RgpRequestResult>>;
/// Type that represents the &lt;rgpStatus&gt; tag for domain rgp restore request response
#[derive(Serialize, Deserialize, Debug)]
pub struct RgpStatus {
/// The domain RGP status
#[serde(rename = "s")]
pub status: String,
}
#[derive(Serialize, Deserialize, Debug, ElementName)]
#[serde(rename = "upData")]
#[element_name(name = "upData")]
/// Type that represents the &lt;resData&gt; tag for domain transfer response
pub struct RgpRequestResult {
#[serde(rename = "xmlns:rgp")]
xmlns: String,
/// Data under the &lt;rgpStatus&gt; tag
#[serde(rename = "rgpStatus")]
pub rgp_status: RgpStatus,
}

View File

@ -8,6 +8,7 @@ mod response {
use crate::domain::delete::EppDomainDeleteResponse; use crate::domain::delete::EppDomainDeleteResponse;
use crate::domain::info::EppDomainInfoResponse; use crate::domain::info::EppDomainInfoResponse;
use crate::domain::renew::EppDomainRenewResponse; use crate::domain::renew::EppDomainRenewResponse;
use crate::domain::rgp::request::EppDomainRgpRestoreRequestResponse;
use crate::domain::transfer::EppDomainTransferApproveResponse; use crate::domain::transfer::EppDomainTransferApproveResponse;
use crate::domain::transfer::EppDomainTransferCancelResponse; use crate::domain::transfer::EppDomainTransferCancelResponse;
use crate::domain::transfer::EppDomainTransferQueryResponse; use crate::domain::transfer::EppDomainTransferQueryResponse;

View File

@ -9,6 +9,7 @@ mod request {
use crate::domain::info::EppDomainInfo; use crate::domain::info::EppDomainInfo;
use crate::domain::renew::EppDomainRenew; use crate::domain::renew::EppDomainRenew;
use crate::domain::rgp::report::EppDomainRgpRestoreReport; use crate::domain::rgp::report::EppDomainRgpRestoreReport;
use crate::domain::rgp::request::EppDomainRgpRestoreRequest;
use crate::domain::transfer::EppDomainTransferApprove; use crate::domain::transfer::EppDomainTransferApprove;
use crate::domain::transfer::EppDomainTransferCancel; use crate::domain::transfer::EppDomainTransferCancel;
use crate::domain::transfer::EppDomainTransferQuery; use crate::domain::transfer::EppDomainTransferQuery;