fixed messy handling of <hostObj> and <hostAttr> in domain create request
This commit is contained in:
parent
9061097641
commit
d0c553cebb
|
@ -74,14 +74,20 @@ use serde::{Deserialize, Serialize};
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainCreate = EppObject<Command<DomainCreate<HostObjList>>>;
|
pub type EppDomainCreate = EppObject<Command<DomainCreate>>;
|
||||||
/// Type that represents the <epp> request for domain <create> command
|
|
||||||
/// with <hostAttr> elements in the request for <ns> list
|
/// Enum that can accept one type which corresponds to either the <hostObj> or <hostAttr>
|
||||||
pub type EppDomainCreateWithHostAttr = EppObject<Command<DomainCreate<HostAttrList>>>;
|
/// list of tags
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum HostList {
|
||||||
|
HostObjList(HostObjList),
|
||||||
|
HostAttrList(HostAttrList),
|
||||||
|
}
|
||||||
|
|
||||||
/// Type for elements under the domain <create> tag
|
/// Type for elements under the domain <create> tag
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct DomainCreateData<T> {
|
pub struct DomainCreateData {
|
||||||
/// XML namespace for domain commands
|
/// XML namespace for domain commands
|
||||||
xmlns: String,
|
xmlns: String,
|
||||||
/// The domain name
|
/// The domain name
|
||||||
|
@ -90,7 +96,7 @@ pub struct DomainCreateData<T> {
|
||||||
period: Period,
|
period: Period,
|
||||||
/// The list of nameserver hosts
|
/// The list of nameserver hosts
|
||||||
/// either of type `HostObjList` or `HostAttrList`
|
/// either of type `HostObjList` or `HostAttrList`
|
||||||
ns: Option<T>,
|
ns: Option<HostList>,
|
||||||
/// The domain registrant
|
/// The domain registrant
|
||||||
registrant: Option<StringValue>,
|
registrant: Option<StringValue>,
|
||||||
/// The list of contacts for the domain
|
/// The list of contacts for the domain
|
||||||
|
@ -104,12 +110,12 @@ pub struct DomainCreateData<T> {
|
||||||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||||
#[element_name(name = "create")]
|
#[element_name(name = "create")]
|
||||||
/// Type for EPP XML <create> command for domains
|
/// Type for EPP XML <create> command for domains
|
||||||
pub struct DomainCreate<T> {
|
pub struct DomainCreate {
|
||||||
/// The data for the domain to be created with
|
/// The data for the domain to be created with
|
||||||
/// T being the type of nameserver list (`HostObjList` or `HostAttrList`)
|
/// T being the type of nameserver list (`HostObjList` or `HostAttrList`)
|
||||||
/// to be supplied
|
/// to be supplied
|
||||||
#[serde(rename = "create")]
|
#[serde(rename = "create")]
|
||||||
domain: DomainCreateData<T>,
|
domain: DomainCreateData,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EppDomainCreate {
|
impl EppDomainCreate {
|
||||||
|
@ -134,17 +140,14 @@ impl EppDomainCreate {
|
||||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||||
name: name.to_string_value(),
|
name: name.to_string_value(),
|
||||||
period: Period::new(period),
|
period: Period::new(period),
|
||||||
ns: Some(HostObjList { hosts: ns_list }),
|
ns: Some(HostList::HostObjList(HostObjList { hosts: ns_list })),
|
||||||
registrant: Some(registrant_id.to_string_value()),
|
registrant: Some(registrant_id.to_string_value()),
|
||||||
auth_info: AuthInfo::new(auth_password),
|
auth_info: AuthInfo::new(auth_password),
|
||||||
contacts: Some(contacts),
|
contacts: Some(contacts),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
EppObject::build(Command::<DomainCreate<HostObjList>>::new(
|
EppObject::build(Command::<DomainCreate>::new(domain_create, client_tr_id))
|
||||||
domain_create,
|
|
||||||
client_tr_id,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new EppObject for domain create corresponding to the <epp> tag in EPP XML
|
/// Creates a new EppObject for domain create corresponding to the <epp> tag in EPP XML
|
||||||
|
@ -168,10 +171,7 @@ impl EppDomainCreate {
|
||||||
contacts: Some(contacts),
|
contacts: Some(contacts),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
EppObject::build(Command::<DomainCreate<HostObjList>>::new(
|
EppObject::build(Command::<DomainCreate>::new(domain_create, client_tr_id))
|
||||||
domain_create,
|
|
||||||
client_tr_id,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new EppObject for domain create corresponding to the <epp> tag in EPP XML
|
/// Creates a new EppObject for domain create corresponding to the <epp> tag in EPP XML
|
||||||
|
@ -194,10 +194,7 @@ impl EppDomainCreate {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
EppObject::build(Command::<DomainCreate<HostObjList>>::new(
|
EppObject::build(Command::<DomainCreate>::new(domain_create, client_tr_id))
|
||||||
domain_create,
|
|
||||||
client_tr_id,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new EppObject for domain create corresponding to the <epp> tag in EPP XML
|
/// Creates a new EppObject for domain create corresponding to the <epp> tag in EPP XML
|
||||||
|
@ -210,21 +207,18 @@ impl EppDomainCreate {
|
||||||
auth_password: &str,
|
auth_password: &str,
|
||||||
contacts: Vec<DomainContact>,
|
contacts: Vec<DomainContact>,
|
||||||
client_tr_id: &str,
|
client_tr_id: &str,
|
||||||
) -> EppDomainCreateWithHostAttr {
|
) -> EppDomainCreate {
|
||||||
let domain_create = DomainCreate {
|
let domain_create = DomainCreate {
|
||||||
domain: DomainCreateData {
|
domain: DomainCreateData {
|
||||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||||
name: name.to_string_value(),
|
name: name.to_string_value(),
|
||||||
period: Period::new(period),
|
period: Period::new(period),
|
||||||
ns: Some(HostAttrList { hosts: ns }),
|
ns: Some(HostList::HostAttrList(HostAttrList { hosts: ns })),
|
||||||
registrant: Some(registrant_id.to_string_value()),
|
registrant: Some(registrant_id.to_string_value()),
|
||||||
auth_info: AuthInfo::new(auth_password),
|
auth_info: AuthInfo::new(auth_password),
|
||||||
contacts: Some(contacts),
|
contacts: Some(contacts),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
EppObject::build(Command::<DomainCreate<HostAttrList>>::new(
|
EppObject::build(Command::<DomainCreate>::new(domain_create, client_tr_id))
|
||||||
domain_create,
|
|
||||||
client_tr_id,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue