fix <hostObj> and <hostAttr> tags for domain update
This commit is contained in:
parent
5d54101317
commit
bb23fb5201
|
@ -64,6 +64,15 @@ pub struct HostAttr {
|
||||||
pub addresses: Option<Vec<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
|
/// The list of <hostAttr> types for domain transactions. Typically under an <ns> tag
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct HostAttrList {
|
pub struct HostAttrList {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use epp_client_macros::*;
|
use epp_client_macros::*;
|
||||||
|
|
||||||
use crate::epp::object::data::{
|
use crate::epp::object::data::{
|
||||||
AuthInfo, DomainContact, HostAttr, HostAttrList, HostObjList, Period,
|
AuthInfo, DomainContact, HostAttr, HostAttrList, HostList, HostObjList, Period,
|
||||||
};
|
};
|
||||||
use crate::epp::object::{ElementName, EppObject, StringValue, StringValueTrait};
|
use crate::epp::object::{ElementName, EppObject, StringValue, StringValueTrait};
|
||||||
use crate::epp::request::Command;
|
use crate::epp::request::Command;
|
||||||
|
@ -78,15 +78,6 @@ use serde::{Deserialize, Serialize};
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainCreate = EppObject<Command<DomainCreate>>;
|
pub type EppDomainCreate = EppObject<Command<DomainCreate>>;
|
||||||
|
|
||||||
/// 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),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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 {
|
pub struct DomainCreateData {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
use epp_client_macros::*;
|
use epp_client_macros::*;
|
||||||
|
|
||||||
use crate::epp::object::data::HostObjList;
|
|
||||||
use crate::epp::object::{ElementName, EppObject, StringValue, StringValueTrait};
|
use crate::epp::object::{ElementName, EppObject, StringValue, StringValueTrait};
|
||||||
use crate::epp::request::domain::update::{DomainChangeInfo, DomainUpdate, DomainUpdateData};
|
use crate::epp::request::domain::update::{DomainChangeInfo, DomainUpdate, DomainUpdateData};
|
||||||
use crate::epp::request::{CommandWithExtension, Extension};
|
use crate::epp::request::{CommandWithExtension, Extension};
|
||||||
|
@ -84,7 +83,7 @@ use serde::{Deserialize, Serialize};
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainRgpRestoreReport =
|
pub type EppDomainRgpRestoreReport =
|
||||||
EppObject<CommandWithExtension<DomainUpdate<HostObjList>, RgpRestoreReport>>;
|
EppObject<CommandWithExtension<DomainUpdate, RgpRestoreReport>>;
|
||||||
|
|
||||||
/// Type corresponding to the <report> section in the EPP rgp restore extension
|
/// Type corresponding to the <report> section in the EPP rgp restore extension
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
@ -152,7 +151,7 @@ impl EppDomainRgpRestoreReport {
|
||||||
.map(|s| s.to_string_value())
|
.map(|s| s.to_string_value())
|
||||||
.collect::<Vec<StringValue>>();
|
.collect::<Vec<StringValue>>();
|
||||||
|
|
||||||
let command = CommandWithExtension::<DomainUpdate<HostObjList>, RgpRestoreReport> {
|
let command = CommandWithExtension::<DomainUpdate, RgpRestoreReport> {
|
||||||
command: DomainUpdate {
|
command: DomainUpdate {
|
||||||
domain: DomainUpdateData {
|
domain: DomainUpdateData {
|
||||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
use epp_client_macros::*;
|
use epp_client_macros::*;
|
||||||
|
|
||||||
use crate::epp::object::data::HostObjList;
|
|
||||||
use crate::epp::object::{ElementName, EppObject, StringValueTrait};
|
use crate::epp::object::{ElementName, EppObject, StringValueTrait};
|
||||||
use crate::epp::request::domain::update::{DomainChangeInfo, DomainUpdate, DomainUpdateData};
|
use crate::epp::request::domain::update::{DomainChangeInfo, DomainUpdate, DomainUpdateData};
|
||||||
use crate::epp::request::{CommandWithExtension, Extension};
|
use crate::epp::request::{CommandWithExtension, Extension};
|
||||||
|
@ -61,7 +60,7 @@ use serde::{Deserialize, Serialize};
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainRgpRestoreRequest =
|
pub type EppDomainRgpRestoreRequest =
|
||||||
EppObject<CommandWithExtension<DomainUpdate<HostObjList>, RgpRestoreRequest>>;
|
EppObject<CommandWithExtension<DomainUpdate, RgpRestoreRequest>>;
|
||||||
|
|
||||||
/// Type corresponding to the <restore> tag for an rgp restore request
|
/// Type corresponding to the <restore> tag for an rgp restore request
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
@ -86,7 +85,7 @@ pub struct RgpRestoreRequest {
|
||||||
impl EppDomainRgpRestoreRequest {
|
impl EppDomainRgpRestoreRequest {
|
||||||
/// Creates a new EppObject for domain rgp restore request corresponding to the <epp> tag in EPP XML
|
/// 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 {
|
pub fn new(name: &str, client_tr_id: &str) -> EppDomainRgpRestoreRequest {
|
||||||
let command = CommandWithExtension::<DomainUpdate<HostObjList>, RgpRestoreRequest> {
|
let command = CommandWithExtension::<DomainUpdate, RgpRestoreRequest> {
|
||||||
command: DomainUpdate {
|
command: DomainUpdate {
|
||||||
domain: DomainUpdateData {
|
domain: DomainUpdateData {
|
||||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use epp_client_macros::*;
|
use epp_client_macros::*;
|
||||||
|
|
||||||
use crate::epp::object::data::{AuthInfo, DomainContact, DomainStatus, HostAttrList, HostObjList};
|
use crate::epp::object::data::{AuthInfo, DomainContact, DomainStatus, HostList};
|
||||||
use crate::epp::object::{ElementName, EppObject, StringValue, StringValueTrait};
|
use crate::epp::object::{ElementName, EppObject, StringValue, StringValueTrait};
|
||||||
use crate::epp::request::Command;
|
use crate::epp::request::Command;
|
||||||
use crate::epp::xml::EPP_DOMAIN_XMLNS;
|
use crate::epp::xml::EPP_DOMAIN_XMLNS;
|
||||||
|
@ -80,10 +80,7 @@ use serde::{Deserialize, Serialize};
|
||||||
/// client.logout().await.unwrap();
|
/// client.logout().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainUpdate = EppObject<Command<DomainUpdate<HostObjList>>>;
|
pub type EppDomainUpdate = EppObject<Command<DomainUpdate>>;
|
||||||
/// Type that represents the <epp> request for domain <update> command
|
|
||||||
/// with <hostAttr> elements in the request for <ns> list
|
|
||||||
pub type EppDomainUpdateWithHostAttr = EppObject<Command<DomainUpdate<HostAttrList>>>;
|
|
||||||
|
|
||||||
/// Type for elements under the <chg> tag for domain update
|
/// Type for elements under the <chg> tag for domain update
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
@ -97,11 +94,11 @@ pub struct DomainChangeInfo {
|
||||||
|
|
||||||
/// Type for elements under the <add> and <rem> tags for domain update
|
/// Type for elements under the <add> and <rem> tags for domain update
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct DomainAddRemove<T> {
|
pub struct DomainAddRemove {
|
||||||
/// The list of nameservers to add or remove
|
/// The list of nameservers to add or remove
|
||||||
/// Type T can be either a `HostObjList` or `HostAttrList`
|
/// Type T can be either a `HostObjList` or `HostAttrList`
|
||||||
#[serde(rename = "ns")]
|
#[serde(rename = "ns")]
|
||||||
pub ns: Option<T>,
|
pub ns: Option<HostList>,
|
||||||
/// The list of contacts to add to or remove from the domain
|
/// The list of contacts to add to or remove from the domain
|
||||||
#[serde(rename = "contact")]
|
#[serde(rename = "contact")]
|
||||||
pub contacts: Option<Vec<DomainContact>>,
|
pub contacts: Option<Vec<DomainContact>>,
|
||||||
|
@ -112,18 +109,18 @@ pub struct DomainAddRemove<T> {
|
||||||
|
|
||||||
/// Type for elements under the <update> tag for domain update
|
/// Type for elements under the <update> tag for domain update
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct DomainUpdateData<T> {
|
pub struct DomainUpdateData {
|
||||||
/// XML namespace for domain commands
|
/// XML namespace for domain commands
|
||||||
pub xmlns: String,
|
pub xmlns: String,
|
||||||
/// The name of the domain to update
|
/// The name of the domain to update
|
||||||
pub name: StringValue,
|
pub name: StringValue,
|
||||||
/// `DomainAddRemove` Object containing the list of elements to be added
|
/// `DomainAddRemove` Object containing the list of elements to be added
|
||||||
/// to the domain
|
/// to the domain
|
||||||
pub add: Option<DomainAddRemove<T>>,
|
pub add: Option<DomainAddRemove>,
|
||||||
/// `DomainAddRemove` Object containing the list of elements to be removed
|
/// `DomainAddRemove` Object containing the list of elements to be removed
|
||||||
/// from the domain
|
/// from the domain
|
||||||
#[serde(rename = "rem")]
|
#[serde(rename = "rem")]
|
||||||
pub remove: Option<DomainAddRemove<T>>,
|
pub remove: Option<DomainAddRemove>,
|
||||||
/// The data under the <chg> tag for domain update
|
/// The data under the <chg> tag for domain update
|
||||||
#[serde(rename = "chg")]
|
#[serde(rename = "chg")]
|
||||||
pub change_info: Option<DomainChangeInfo>,
|
pub change_info: Option<DomainChangeInfo>,
|
||||||
|
@ -132,16 +129,16 @@ pub struct DomainUpdateData<T> {
|
||||||
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
#[derive(Serialize, Deserialize, Debug, ElementName)]
|
||||||
#[element_name(name = "update")]
|
#[element_name(name = "update")]
|
||||||
/// Type for EPP XML <update> command for domains
|
/// Type for EPP XML <update> command for domains
|
||||||
pub struct DomainUpdate<T> {
|
pub struct DomainUpdate {
|
||||||
#[serde(rename = "update")]
|
#[serde(rename = "update")]
|
||||||
pub domain: DomainUpdateData<T>,
|
pub domain: DomainUpdateData,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EppDomainUpdate {
|
impl EppDomainUpdate {
|
||||||
/// Creates a new EppObject for domain update corresponding to the <epp> tag in EPP XML
|
/// Creates a new EppObject for domain update corresponding to the <epp> tag in EPP XML
|
||||||
/// with the <ns> tag containing <hostObj> tags
|
/// with the <ns> tag containing <hostObj> tags
|
||||||
pub fn new(name: &str, client_tr_id: &str) -> EppDomainUpdate {
|
pub fn new(name: &str, client_tr_id: &str) -> EppDomainUpdate {
|
||||||
EppObject::build(Command::<DomainUpdate<HostObjList>>::new(
|
EppObject::build(Command::<DomainUpdate>::new(
|
||||||
DomainUpdate {
|
DomainUpdate {
|
||||||
domain: DomainUpdateData {
|
domain: DomainUpdateData {
|
||||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||||
|
@ -161,46 +158,12 @@ impl EppDomainUpdate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the data for the <add> tag
|
/// Sets the data for the <add> tag
|
||||||
pub fn add(&mut self, add: DomainAddRemove<HostObjList>) {
|
pub fn add(&mut self, add: DomainAddRemove) {
|
||||||
self.data.command.domain.add = Some(add);
|
self.data.command.domain.add = Some(add);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the data for the <rem> tag
|
/// Sets the data for the <rem> tag
|
||||||
pub fn remove(&mut self, remove: DomainAddRemove<HostObjList>) {
|
pub fn remove(&mut self, remove: DomainAddRemove) {
|
||||||
self.data.command.domain.remove = Some(remove);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EppDomainUpdateWithHostAttr {
|
|
||||||
/// Creates a new EppObject for domain update corresponding to the <epp> tag in EPP XML
|
|
||||||
/// with the <ns> tag containing <hostAttr> tags
|
|
||||||
pub fn new(name: &str, client_tr_id: &str) -> EppDomainUpdateWithHostAttr {
|
|
||||||
EppObject::build(Command::<DomainUpdate<HostAttrList>>::new(
|
|
||||||
DomainUpdate {
|
|
||||||
domain: DomainUpdateData {
|
|
||||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
|
||||||
name: name.to_string_value(),
|
|
||||||
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<HostAttrList>) {
|
|
||||||
self.data.command.domain.add = Some(add);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the data for the <rem> tag
|
|
||||||
pub fn remove(&mut self, remove: DomainAddRemove<HostAttrList>) {
|
|
||||||
self.data.command.domain.remove = Some(remove);
|
self.data.command.domain.remove = Some(remove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue