tested domain creation call
This commit is contained in:
parent
5f0a5092a5
commit
5c9afa665b
|
@ -1,29 +1,26 @@
|
|||
use epp_client::{epp::request::generate_client_tr_id, connection::client::EppClient, connection, epp::xml::EppXml};
|
||||
use epp_client::epp::object::StringValueTrait;
|
||||
use epp_client::epp::object::data::ContactStatus;
|
||||
use epp_client::epp::request::domain::check::EppDomainCheck;
|
||||
use epp_client::epp::response::domain::check::EppDomainCheckResponse;
|
||||
use epp_client::epp::request::contact::check::EppContactCheck;
|
||||
use epp_client::epp::response::contact::check::EppContactCheckResponse;
|
||||
use epp_client::epp::object::data::{PostalInfo, Address, Phone};
|
||||
use epp_client::epp::request::contact::create::EppContactCreate;
|
||||
use epp_client::epp::response::contact::create::EppContactCreateResponse;
|
||||
use epp_client::epp::request::contact::info::EppContactInfo;
|
||||
use epp_client::epp::response::contact::info::EppContactInfoResponse;
|
||||
use epp_client::epp::request::contact::update::EppContactUpdate;
|
||||
use epp_client::epp::response::contact::update::EppContactUpdateResponse;
|
||||
use epp_client::epp::request::contact::delete::EppContactDelete;
|
||||
use epp_client::epp::response::contact::delete::EppContactDeleteResponse;
|
||||
use epp_client::epp::request::domain::create::DomainContact;
|
||||
use epp_client::epp::request::domain::create::{HostObjList, HostAttrList};
|
||||
use epp_client::epp::request::domain::create::EppDomainCreate;
|
||||
//use epp_client::epp::response::domain::create::EppDomainCreateResponse;
|
||||
use epp_client::EppClient;
|
||||
use epp_client::{epp::request::generate_client_tr_id, epp::xml::EppXml};
|
||||
use epp_client::epp::object::data::{PostalInfo, Address, Phone, DomainContact, ContactStatus};
|
||||
use epp_client::epp::EppDomainCheck;
|
||||
use epp_client::epp::EppDomainCheckResponse;
|
||||
use epp_client::epp::EppContactCheck;
|
||||
use epp_client::epp::EppContactCheckResponse;
|
||||
use epp_client::epp::EppContactCreate;
|
||||
use epp_client::epp::EppContactCreateResponse;
|
||||
use epp_client::epp::EppContactInfo;
|
||||
use epp_client::epp::EppContactInfoResponse;
|
||||
use epp_client::epp::EppContactUpdate;
|
||||
use epp_client::epp::EppContactUpdateResponse;
|
||||
use epp_client::epp::EppContactDelete;
|
||||
use epp_client::epp::EppContactDeleteResponse;
|
||||
use epp_client::epp::EppDomainCreate;
|
||||
use epp_client::epp::EppDomainCreateResponse;
|
||||
|
||||
async fn check_domains(client: &mut EppClient) {
|
||||
let domains = vec!["eppdev.com", "hexonet.net"];
|
||||
let domain_check = EppDomainCheck::new(domains, generate_client_tr_id("eppdev").unwrap().as_str());
|
||||
|
||||
client.transact::<EppDomainCheck, EppDomainCheckResponse>(&domain_check).await.unwrap();
|
||||
client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap();
|
||||
}
|
||||
|
||||
async fn check_contacts(client: &mut EppClient) {
|
||||
|
@ -42,7 +39,7 @@ async fn create_contact(client: &mut EppClient) {
|
|||
let mut fax = Phone::new("+47.86698799");
|
||||
fax.set_extension("677");
|
||||
|
||||
let mut contact_create = EppContactCreate::new("eppdev-contact-1", "contact@eppdev.net", postal_info, voice, "eppdev-387323", generate_client_tr_id("eppdev").unwrap().as_str());
|
||||
let mut contact_create = EppContactCreate::new("eppdev-contact-2", "contact@eppdev.net", postal_info, voice, "eppdev-387323", generate_client_tr_id("eppdev").unwrap().as_str());
|
||||
contact_create.set_fax(fax);
|
||||
|
||||
// println!("xml: {}", contact_create.serialize().unwrap());
|
||||
|
@ -66,7 +63,7 @@ async fn update_contact(client: &mut EppClient) {
|
|||
}
|
||||
|
||||
async fn query_contact(client: &mut EppClient) {
|
||||
let mut contact_info = EppContactInfo::new("eppdev-contact-1", "eppdev-387323", generate_client_tr_id("eppdev").unwrap().as_str());
|
||||
let mut contact_info = EppContactInfo::new("eppdev-contact-2", "eppdev-387323", generate_client_tr_id("eppdev").unwrap().as_str());
|
||||
|
||||
client.transact::<_, EppContactInfoResponse>(&contact_info).await.unwrap();
|
||||
}
|
||||
|
@ -77,20 +74,28 @@ async fn delete_contact(client: &mut EppClient) {
|
|||
client.transact::<_, EppContactDeleteResponse>(&contact_delete).await.unwrap();
|
||||
}
|
||||
|
||||
async fn create_domain() {
|
||||
async fn create_domain(client: &mut EppClient) {
|
||||
let contacts = vec![
|
||||
DomainContact {
|
||||
contact_type: "admin".to_string(),
|
||||
id: "eppdev-contact-2".to_string()
|
||||
},
|
||||
DomainContact {
|
||||
contact_type: "tech".to_string(),
|
||||
id: "eppdev-contact-1".to_string()
|
||||
id: "eppdev-contact-2".to_string()
|
||||
},
|
||||
DomainContact {
|
||||
contact_type: "billing".to_string(),
|
||||
id: "eppdev-contact-1".to_string()
|
||||
id: "eppdev-contact-2".to_string()
|
||||
}
|
||||
];
|
||||
let domain_create = EppDomainCreate::<HostAttrList>::new("eppdev.com", 1, vec!["ns1.test.com", "ns2.test.com"], "eppdev-contact-1", "eppdevauth123", contacts, generate_client_tr_id("eppdev").unwrap().as_str());
|
||||
// let domain_create = EppDomainCreate::new_with_ns("eppdev.com", 1, vec!["ns1.test.com", "ns2.test.com"], "eppdev-contact-1", "eppdevauth123", contacts, generate_client_tr_id("eppdev").unwrap().as_str());
|
||||
|
||||
println!("{}", domain_create.serialize().unwrap());
|
||||
let domain_create = EppDomainCreate::new("eppdev.com", 1, "eppdev-contact-2", "epP4uthd#v", contacts, generate_client_tr_id("eppdev").unwrap().as_str());
|
||||
|
||||
// println!("{}", domain_create.serialize().unwrap());
|
||||
|
||||
client.transact::<_, EppDomainCreateResponse>(&domain_create).await.unwrap();
|
||||
}
|
||||
|
||||
async fn hello(client: &mut EppClient) {
|
||||
|
@ -101,13 +106,13 @@ async fn hello(client: &mut EppClient) {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// let mut client = match EppClient::new("hexonet").await {
|
||||
// Ok(client) => {
|
||||
// println!("{:?}", client.greeting());
|
||||
// client
|
||||
// },
|
||||
// Err(e) => panic!("Error: {}", e)
|
||||
// };
|
||||
let mut client = match EppClient::new("hexonet").await {
|
||||
Ok(client) => {
|
||||
println!("{:?}", client.greeting());
|
||||
client
|
||||
},
|
||||
Err(e) => panic!("Error: {}", e)
|
||||
};
|
||||
|
||||
// hello(&mut client).await;
|
||||
|
||||
|
@ -123,5 +128,5 @@ async fn main() {
|
|||
|
||||
// delete_contact(&mut client).await;
|
||||
|
||||
// create_domain().await;
|
||||
// create_domain(&mut client).await;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use crate::error;
|
|||
use crate::epp::request::{generate_client_tr_id, EppHello, EppLogin, EppLogout};
|
||||
use crate::epp::response::{EppGreeting, EppCommandResponseStatus, EppCommandResponse, EppCommandResponseError};
|
||||
use crate::epp::xml::EppXml;
|
||||
use crate::epp::object::{ElementName, EppObject};
|
||||
|
||||
async fn connect(registry: &'static str) -> Result<EppClient, Box<dyn Error>> {
|
||||
let registry_creds = match CONFIG.registry(registry) {
|
||||
|
|
|
@ -4,3 +4,18 @@ pub mod quick_xml;
|
|||
pub mod request;
|
||||
pub mod response;
|
||||
pub mod xml;
|
||||
|
||||
pub use request::contact::check::*;
|
||||
pub use request::contact::create::*;
|
||||
pub use request::contact::delete::*;
|
||||
pub use request::contact::info::*;
|
||||
pub use request::contact::update::*;
|
||||
pub use request::domain::check::*;
|
||||
pub use request::domain::create::*;
|
||||
pub use response::contact::check::*;
|
||||
pub use response::contact::create::*;
|
||||
pub use response::contact::delete::*;
|
||||
pub use response::contact::info::*;
|
||||
pub use response::contact::update::*;
|
||||
pub use response::domain::check::*;
|
||||
pub use response::domain::create::*;
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
use crate::epp::object::{StringValue, StringValueTrait};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct DomainContact {
|
||||
#[serde(rename = "$value")]
|
||||
pub id: String,
|
||||
#[serde(rename = "type")]
|
||||
pub contact_type: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Period {
|
||||
unit: String,
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use epp_client_macros::*;
|
||||
|
||||
use crate::epp::command::Command;
|
||||
use crate::epp::object::data::{AuthInfo, Period};
|
||||
use crate::epp::object::data::{AuthInfo, DomainContact, Period};
|
||||
use crate::epp::object::{ElementName, EppObject, StringValue, StringValueTrait};
|
||||
use crate::epp::xml::EPP_DOMAIN_XMLNS;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub type EppDomainCreate<T> = EppObject<Command<DomainCreate<T>>>;
|
||||
pub type EppDomainCreate = EppObject<Command<DomainCreate<HostObjList>>>;
|
||||
pub type EppDomainCreateWithHostAttr = EppObject<Command<DomainCreate<HostAttrList>>>;
|
||||
|
||||
pub enum HostType {
|
||||
HostObj,
|
||||
|
@ -17,14 +18,6 @@ pub trait HostList {
|
|||
fn new(ns: Vec<&str>) -> Self;
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct DomainContact {
|
||||
#[serde(rename = "$value")]
|
||||
pub id: String,
|
||||
#[serde(rename = "type")]
|
||||
pub contact_type: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HostAttr {
|
||||
#[serde(rename = "hostName")]
|
||||
|
@ -73,9 +66,9 @@ pub struct DomainData<T> {
|
|||
name: StringValue,
|
||||
period: Period,
|
||||
ns: Option<T>,
|
||||
registrant: StringValue,
|
||||
registrant: Option<StringValue>,
|
||||
#[serde(rename = "contact")]
|
||||
contacts: Vec<DomainContact>,
|
||||
contacts: Option<Vec<DomainContact>>,
|
||||
#[serde(rename = "authInfo")]
|
||||
auth_info: AuthInfo,
|
||||
}
|
||||
|
@ -87,8 +80,8 @@ pub struct DomainCreate<T> {
|
|||
domain: DomainData<T>,
|
||||
}
|
||||
|
||||
impl<T: HostList> EppDomainCreate<T> {
|
||||
pub fn new(
|
||||
impl EppDomainCreate {
|
||||
pub fn new_with_ns(
|
||||
name: &str,
|
||||
period: u16,
|
||||
ns: Vec<&str>,
|
||||
|
@ -96,41 +89,88 @@ impl<T: HostList> EppDomainCreate<T> {
|
|||
auth_password: &str,
|
||||
contacts: Vec<DomainContact>,
|
||||
client_tr_id: &str,
|
||||
) -> EppDomainCreate<T> {
|
||||
EppObject::build(Command::<DomainCreate<T>> {
|
||||
) -> EppDomainCreate {
|
||||
EppObject::build(Command::<DomainCreate<HostObjList>> {
|
||||
command: DomainCreate {
|
||||
domain: DomainData {
|
||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||
name: name.to_string_value(),
|
||||
period: Period::new(period),
|
||||
ns: Some(T::new(ns)),
|
||||
registrant: registrant_id.to_string_value(),
|
||||
ns: Some(HostObjList::new(ns)),
|
||||
registrant: Some(registrant_id.to_string_value()),
|
||||
auth_info: AuthInfo::new(auth_password),
|
||||
contacts: contacts,
|
||||
contacts: Some(contacts),
|
||||
},
|
||||
},
|
||||
client_tr_id: client_tr_id.to_string_value(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new_without_ns(
|
||||
pub fn new(
|
||||
name: &str,
|
||||
period: u16,
|
||||
registrant_id: &str,
|
||||
auth_password: &str,
|
||||
contacts: Vec<DomainContact>,
|
||||
client_tr_id: &str,
|
||||
) -> EppDomainCreate<T> {
|
||||
EppObject::build(Command::<DomainCreate<T>> {
|
||||
) -> EppDomainCreate {
|
||||
EppObject::build(Command::<DomainCreate<HostObjList>> {
|
||||
command: DomainCreate {
|
||||
domain: DomainData {
|
||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||
name: name.to_string_value(),
|
||||
period: Period::new(period),
|
||||
ns: None,
|
||||
registrant: registrant_id.to_string_value(),
|
||||
registrant: Some(registrant_id.to_string_value()),
|
||||
auth_info: AuthInfo::new(auth_password),
|
||||
contacts: contacts,
|
||||
contacts: Some(contacts),
|
||||
},
|
||||
},
|
||||
client_tr_id: client_tr_id.to_string_value(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new_without_contacts(
|
||||
name: &str,
|
||||
period: u16,
|
||||
auth_password: &str,
|
||||
client_tr_id: &str,
|
||||
) -> EppDomainCreate {
|
||||
EppObject::build(Command::<DomainCreate<HostObjList>> {
|
||||
command: DomainCreate {
|
||||
domain: DomainData {
|
||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||
name: name.to_string_value(),
|
||||
period: Period::new(period),
|
||||
ns: None,
|
||||
registrant: None,
|
||||
auth_info: AuthInfo::new(auth_password),
|
||||
contacts: None,
|
||||
},
|
||||
},
|
||||
client_tr_id: client_tr_id.to_string_value(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new_with_host_attr(
|
||||
name: &str,
|
||||
period: u16,
|
||||
ns: Vec<&str>,
|
||||
registrant_id: &str,
|
||||
auth_password: &str,
|
||||
contacts: Vec<DomainContact>,
|
||||
client_tr_id: &str,
|
||||
) -> EppDomainCreateWithHostAttr {
|
||||
EppObject::build(Command::<DomainCreate<HostAttrList>> {
|
||||
command: DomainCreate {
|
||||
domain: DomainData {
|
||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||
name: name.to_string_value(),
|
||||
period: Period::new(period),
|
||||
ns: Some(HostAttrList::new(ns)),
|
||||
registrant: Some(registrant_id.to_string_value()),
|
||||
auth_info: AuthInfo::new(auth_password),
|
||||
contacts: Some(contacts),
|
||||
},
|
||||
},
|
||||
client_tr_id: client_tr_id.to_string_value(),
|
||||
|
|
|
@ -21,6 +21,7 @@ pub struct ContactCheckDataItem {
|
|||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ContactCheckData {
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: String,
|
||||
#[serde(rename = "cd")]
|
||||
pub contact_list: Vec<ContactCheckDataItem>,
|
||||
|
|
|
@ -7,6 +7,7 @@ pub type EppContactCreateResponse = EppObject<CommandResponse<ContactCreateResul
|
|||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ContactCreateData {
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: String,
|
||||
pub id: StringValue,
|
||||
#[serde(rename = "crDate")]
|
||||
|
|
|
@ -8,6 +8,7 @@ pub type EppContactInfoResponse = EppObject<CommandResponse<ContactInfoResult>>;
|
|||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ContactInfoData {
|
||||
#[serde(rename = "xmlns:contact")]
|
||||
xmlns: String,
|
||||
pub id: StringValue,
|
||||
pub roid: StringValue,
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
pub mod check;
|
||||
pub mod create;
|
||||
|
|
|
@ -3,10 +3,11 @@ use serde::{Deserialize, Serialize};
|
|||
use crate::epp::object::{EppObject, StringValue};
|
||||
use crate::epp::response::CommandResponse;
|
||||
|
||||
pub type EppDomainCheckResponse = EppObject<CommandResponse<DomainCheckResult>>;
|
||||
pub type EppDomainCreateResponse = EppObject<CommandResponse<DomainCreateResult>>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct DomainCreateData {
|
||||
#[serde(rename = "xmlns:domain")]
|
||||
xmlns: String,
|
||||
name: StringValue,
|
||||
#[serde(rename = "crDate")]
|
||||
|
|
|
@ -3,6 +3,8 @@ pub mod connection;
|
|||
pub mod epp;
|
||||
pub mod error;
|
||||
|
||||
pub use connection::client::EppClient;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::config;
|
||||
|
|
Loading…
Reference in New Issue