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
|
/// The <status> type on contact transactions
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct ContactStatus {
|
pub struct ContactStatus {
|
||||||
|
@ -266,14 +194,6 @@ pub struct PostalInfo {
|
||||||
pub address: Address,
|
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
|
/// The <authInfo> tag for domain and contact transactions
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct ContactAuthInfo {
|
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 {
|
impl ContactAuthInfo {
|
||||||
/// Creates a ContactAuthInfo instance with the given password
|
/// Creates a ContactAuthInfo instance with the given password
|
||||||
pub fn new(password: &str) -> ContactAuthInfo {
|
pub fn new(password: &str) -> ContactAuthInfo {
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::common::{HostAddr, StringValue};
|
||||||
|
|
||||||
pub mod check;
|
pub mod check;
|
||||||
pub mod create;
|
pub mod create;
|
||||||
pub mod delete;
|
pub mod delete;
|
||||||
|
@ -8,4 +12,91 @@ pub mod update;
|
||||||
|
|
||||||
pub const XMLNS: &str = "urn:ietf:params:xml:ns:domain-1.0";
|
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
|
//! Types for EPP domain create request
|
||||||
|
|
||||||
use super::XMLNS;
|
use super::{DomainAuthInfo, DomainContact, HostList, Period, XMLNS};
|
||||||
use crate::common::{DomainAuthInfo, DomainContact, HostList, NoExtension, Period, StringValue};
|
use crate::common::{NoExtension, StringValue};
|
||||||
use crate::request::{Command, Transaction};
|
use crate::request::{Command, Transaction};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
impl Transaction<NoExtension> for DomainCreate {}
|
impl Transaction<NoExtension> for DomainCreate {}
|
||||||
|
@ -102,10 +103,9 @@ pub struct DomainCreateResponse {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::DomainCreate;
|
use super::{DomainContact, DomainCreate, HostList};
|
||||||
use crate::common::{
|
use crate::common::{HostAddr, NoExtension};
|
||||||
DomainContact, HostAddr, HostAttr, HostAttrList, HostList, HostObjList, NoExtension,
|
use crate::domain::{HostAttr, HostAttrList, HostObjList};
|
||||||
};
|
|
||||||
use crate::request::Transaction;
|
use crate::request::Transaction;
|
||||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
//! Types for EPP domain info request
|
//! Types for EPP domain info request
|
||||||
|
|
||||||
use super::XMLNS;
|
use super::{DomainAuthInfo, DomainContact, HostAttr, XMLNS};
|
||||||
use crate::common::{
|
use crate::common::{DomainStatus, NoExtension, StringValue};
|
||||||
DomainAuthInfo, DomainContact, DomainStatus, HostAttr, NoExtension, StringValue,
|
|
||||||
};
|
|
||||||
use crate::request::{Command, Transaction};
|
use crate::request::{Command, Transaction};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Types for EPP domain renew request
|
//! Types for EPP domain renew request
|
||||||
|
|
||||||
use super::XMLNS;
|
use super::{Period, XMLNS};
|
||||||
use crate::common::{NoExtension, Period, StringValue};
|
use crate::common::{NoExtension, StringValue};
|
||||||
use crate::request::{Command, Transaction};
|
use crate::request::{Command, Transaction};
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Types for EPP domain transfer request
|
//! Types for EPP domain transfer request
|
||||||
|
|
||||||
use super::XMLNS;
|
use super::{DomainAuthInfo, Period, XMLNS};
|
||||||
use crate::common::{DomainAuthInfo, NoExtension, Period, StringValue};
|
use crate::common::{NoExtension, StringValue};
|
||||||
use crate::request::{Command, Transaction};
|
use crate::request::{Command, Transaction};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
//! Types for EPP domain check request
|
//! Types for EPP domain check request
|
||||||
//!
|
//!
|
||||||
|
use super::{DomainAuthInfo, DomainContact, HostList, XMLNS};
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{DomainAuthInfo, DomainContact, DomainStatus, HostList, NoExtension, StringValue},
|
common::{DomainStatus, NoExtension, StringValue},
|
||||||
request::{Command, Transaction},
|
request::{Command, Transaction},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::XMLNS;
|
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
impl Transaction<NoExtension> for DomainUpdate {}
|
impl Transaction<NoExtension> for DomainUpdate {}
|
||||||
|
@ -102,8 +101,8 @@ pub struct DomainUpdate {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{DomainAddRemove, DomainChangeInfo, DomainUpdate};
|
use super::{DomainAddRemove, DomainAuthInfo, DomainChangeInfo, DomainContact, DomainUpdate};
|
||||||
use crate::common::{DomainAuthInfo, DomainContact, DomainStatus, NoExtension};
|
use crate::common::{DomainStatus, NoExtension};
|
||||||
use crate::request::Transaction;
|
use crate::request::Transaction;
|
||||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue