Move domain-related types from common to domain
This commit is contained in:
parent
2ac3a6398d
commit
defd7cff9b
|
@ -119,78 +119,6 @@ impl HostAddr {
|
|||
}
|
||||
}
|
||||
|
||||
/// The <hostAttr> type for domain transactions
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostAttr {
|
||||
/// The <hostName> tag
|
||||
#[serde(rename = "domain:hostName", alias = "hostName")]
|
||||
pub name: StringValue,
|
||||
/// The <hostAddr> tags
|
||||
#[serde(rename = "domain:hostAddr", alias = "hostAddr")]
|
||||
pub addresses: Option<Vec<HostAddr>>,
|
||||
}
|
||||
|
||||
/// Enum that can accept one type which corresponds to either the <hostObj> or <hostAttr>
|
||||
/// list of tags
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(untagged)]
|
||||
pub enum HostList {
|
||||
HostObjList(HostObjList),
|
||||
HostAttrList(HostAttrList),
|
||||
}
|
||||
|
||||
/// The list of <hostAttr> types for domain transactions. Typically under an <ns> tag
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostAttrList {
|
||||
/// The list of <hostAttr> tags
|
||||
#[serde(rename = "domain:hostAttr", alias = "hostAttr")]
|
||||
pub hosts: Vec<HostAttr>,
|
||||
}
|
||||
|
||||
/// The list of <hostObj> types for domain transactions. Typically under an <ns> tag
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostObjList {
|
||||
/// The list of <hostObj> tags
|
||||
#[serde(rename = "domain:hostObj", alias = "hostObj")]
|
||||
pub hosts: Vec<StringValue>,
|
||||
}
|
||||
|
||||
/// The <contact> type on domain creation and update requests
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct DomainContact {
|
||||
/// The contact id
|
||||
#[serde(rename = "$value")]
|
||||
pub id: String,
|
||||
/// The contact type attr (usually admin, billing, or tech in most registries)
|
||||
#[serde(rename = "type")]
|
||||
pub contact_type: String,
|
||||
}
|
||||
|
||||
/// The <period> type for registration, renewal or transfer on domain transactions
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Period {
|
||||
/// The interval (usually 'y' indicating years)
|
||||
unit: String,
|
||||
/// The length of the registration, renewal or transfer period (usually in years)
|
||||
#[serde(rename = "$value")]
|
||||
length: u16,
|
||||
}
|
||||
|
||||
impl Period {
|
||||
/// Creates a new period in years
|
||||
pub fn new(length: u16) -> Period {
|
||||
Period {
|
||||
unit: "y".to_string(),
|
||||
length,
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the period unit ('y' for years, most commonly)
|
||||
pub fn set_unit(&mut self, unit: &str) {
|
||||
self.unit = unit.to_string();
|
||||
}
|
||||
}
|
||||
|
||||
/// The <status> type on contact transactions
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ContactStatus {
|
||||
|
@ -266,14 +194,6 @@ pub struct PostalInfo {
|
|||
pub address: Address,
|
||||
}
|
||||
|
||||
/// The <authInfo> tag for domain and contact transactions
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct DomainAuthInfo {
|
||||
/// The <pw> tag under <authInfo>
|
||||
#[serde(rename = "domain:pw", alias = "pw")]
|
||||
pub password: StringValue,
|
||||
}
|
||||
|
||||
/// The <authInfo> tag for domain and contact transactions
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct ContactAuthInfo {
|
||||
|
@ -297,15 +217,6 @@ impl Phone {
|
|||
}
|
||||
}
|
||||
|
||||
impl DomainAuthInfo {
|
||||
/// Creates a DomainAuthInfo instance with the given password
|
||||
pub fn new(password: &str) -> DomainAuthInfo {
|
||||
DomainAuthInfo {
|
||||
password: password.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ContactAuthInfo {
|
||||
/// Creates a ContactAuthInfo instance with the given password
|
||||
pub fn new(password: &str) -> ContactAuthInfo {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::common::{HostAddr, StringValue};
|
||||
|
||||
pub mod check;
|
||||
pub mod create;
|
||||
pub mod delete;
|
||||
|
@ -8,4 +12,91 @@ pub mod update;
|
|||
|
||||
pub const XMLNS: &str = "urn:ietf:params:xml:ns:domain-1.0";
|
||||
|
||||
/// The <hostAttr> type for domain transactions
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostAttr {
|
||||
/// The <hostName> tag
|
||||
#[serde(rename = "domain:hostName", alias = "hostName")]
|
||||
pub name: StringValue,
|
||||
/// The <hostAddr> tags
|
||||
#[serde(rename = "domain:hostAddr", alias = "hostAddr")]
|
||||
pub addresses: Option<Vec<HostAddr>>,
|
||||
}
|
||||
|
||||
/// The list of <hostAttr> types for domain transactions. Typically under an <ns> tag
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostAttrList {
|
||||
/// The list of <hostAttr> tags
|
||||
#[serde(rename = "domain:hostAttr", alias = "hostAttr")]
|
||||
pub hosts: Vec<HostAttr>,
|
||||
}
|
||||
|
||||
/// The list of <hostObj> types for domain transactions. Typically under an <ns> tag
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostObjList {
|
||||
/// The list of <hostObj> tags
|
||||
#[serde(rename = "domain:hostObj", alias = "hostObj")]
|
||||
pub hosts: Vec<StringValue>,
|
||||
}
|
||||
|
||||
/// Enum that can accept one type which corresponds to either the <hostObj> or <hostAttr>
|
||||
/// list of tags
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(untagged)]
|
||||
pub enum HostList {
|
||||
HostObjList(HostObjList),
|
||||
HostAttrList(HostAttrList),
|
||||
}
|
||||
|
||||
/// The <contact> type on domain creation and update requests
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct DomainContact {
|
||||
/// The contact id
|
||||
#[serde(rename = "$value")]
|
||||
pub id: String,
|
||||
/// The contact type attr (usually admin, billing, or tech in most registries)
|
||||
#[serde(rename = "type")]
|
||||
pub contact_type: String,
|
||||
}
|
||||
|
||||
/// The <period> type for registration, renewal or transfer on domain transactions
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Period {
|
||||
/// The interval (usually 'y' indicating years)
|
||||
unit: String,
|
||||
/// The length of the registration, renewal or transfer period (usually in years)
|
||||
#[serde(rename = "$value")]
|
||||
length: u16,
|
||||
}
|
||||
|
||||
impl Period {
|
||||
/// Creates a new period in years
|
||||
pub fn new(length: u16) -> Period {
|
||||
Period {
|
||||
unit: "y".to_string(),
|
||||
length,
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the period unit ('y' for years, most commonly)
|
||||
pub fn set_unit(&mut self, unit: &str) {
|
||||
self.unit = unit.to_string();
|
||||
}
|
||||
}
|
||||
|
||||
/// The <authInfo> tag for domain and contact transactions
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct DomainAuthInfo {
|
||||
/// The <pw> tag under <authInfo>
|
||||
#[serde(rename = "domain:pw", alias = "pw")]
|
||||
pub password: StringValue,
|
||||
}
|
||||
|
||||
impl DomainAuthInfo {
|
||||
/// Creates a DomainAuthInfo instance with the given password
|
||||
pub fn new(password: &str) -> DomainAuthInfo {
|
||||
DomainAuthInfo {
|
||||
password: password.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
//! Types for EPP domain create request
|
||||
|
||||
use super::XMLNS;
|
||||
use crate::common::{DomainAuthInfo, DomainContact, HostList, NoExtension, Period, StringValue};
|
||||
use super::{DomainAuthInfo, DomainContact, HostList, Period, XMLNS};
|
||||
use crate::common::{NoExtension, StringValue};
|
||||
use crate::request::{Command, Transaction};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for DomainCreate {}
|
||||
|
@ -102,10 +103,9 @@ pub struct DomainCreateResponse {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::DomainCreate;
|
||||
use crate::common::{
|
||||
DomainContact, HostAddr, HostAttr, HostAttrList, HostList, HostObjList, NoExtension,
|
||||
};
|
||||
use super::{DomainContact, DomainCreate, HostList};
|
||||
use crate::common::{HostAddr, NoExtension};
|
||||
use crate::domain::{HostAttr, HostAttrList, HostObjList};
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
//! Types for EPP domain info request
|
||||
|
||||
use super::XMLNS;
|
||||
use crate::common::{
|
||||
DomainAuthInfo, DomainContact, DomainStatus, HostAttr, NoExtension, StringValue,
|
||||
};
|
||||
use super::{DomainAuthInfo, DomainContact, HostAttr, XMLNS};
|
||||
use crate::common::{DomainStatus, NoExtension, StringValue};
|
||||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Types for EPP domain renew request
|
||||
|
||||
use super::XMLNS;
|
||||
use crate::common::{NoExtension, Period, StringValue};
|
||||
use super::{Period, XMLNS};
|
||||
use crate::common::{NoExtension, StringValue};
|
||||
use crate::request::{Command, Transaction};
|
||||
use chrono::NaiveDate;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Types for EPP domain transfer request
|
||||
|
||||
use super::XMLNS;
|
||||
use crate::common::{DomainAuthInfo, NoExtension, Period, StringValue};
|
||||
use super::{DomainAuthInfo, Period, XMLNS};
|
||||
use crate::common::{NoExtension, StringValue};
|
||||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
//! Types for EPP domain check request
|
||||
//!
|
||||
use super::{DomainAuthInfo, DomainContact, HostList, XMLNS};
|
||||
use crate::{
|
||||
common::{DomainAuthInfo, DomainContact, DomainStatus, HostList, NoExtension, StringValue},
|
||||
common::{DomainStatus, NoExtension, StringValue},
|
||||
request::{Command, Transaction},
|
||||
};
|
||||
|
||||
use super::XMLNS;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
impl Transaction<NoExtension> for DomainUpdate {}
|
||||
|
@ -102,8 +101,8 @@ pub struct DomainUpdate {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{DomainAddRemove, DomainChangeInfo, DomainUpdate};
|
||||
use crate::common::{DomainAuthInfo, DomainContact, DomainStatus, NoExtension};
|
||||
use super::{DomainAddRemove, DomainAuthInfo, DomainChangeInfo, DomainContact, DomainUpdate};
|
||||
use crate::common::{DomainStatus, NoExtension};
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
|
|
Loading…
Reference in New Issue