Add namestore extension model

This commit is contained in:
Nicholas Rempel 2021-12-02 10:28:37 -08:00 committed by masalachai
parent 02cb2c1c26
commit 2e0165a839
3 changed files with 90 additions and 1 deletions

View File

@ -98,7 +98,7 @@ impl Options {
#[serde(rename = "extension")] #[serde(rename = "extension")]
pub struct Extension<E: ElementName> { pub struct Extension<E: ElementName> {
/// Data under the &lt;extension&gt; tag /// Data under the &lt;extension&gt; tag
#[serde(alias = "upData")] #[serde(alias = "upData", alias = "namestoreExt")]
pub data: E, pub data: E,
} }

View File

@ -0,0 +1,88 @@
//! Types for EPP namestore request and responses
use epp_client_macros::ElementName;
use serde::{Deserialize, Serialize};
use crate::{
common::{ElementName, StringValue},
request::EppExtension,
};
pub const XMLNS: &str = "http://www.verisign-grs.com/epp/namestoreExt-1.1";
/// Type that represents the &lt;epp&gt; request for domain &lt;check&gt; command
///
/// ## Usage
///
/// ```no_run
/// use std::collections::HashMap;
///
/// use epp_client::config::{EppClientConfig, RegistryConfig};
/// use epp_client::EppClient;
/// use epp_client::domain::check::DomainCheck;
/// use epp_client::generate_client_tr_id;
/// use epp_client::extensions::namestore::NameStore;
///
/// #[tokio::main]
/// async fn main() {
/// // Create a config
/// let mut registry: HashMap<String, RegistryConfig> = HashMap::new();
/// registry.insert(
/// "registry_name".to_owned(),
/// RegistryConfig {
/// host: "example.com".to_owned(),
/// port: 700,
/// username: "username".to_owned(),
/// password: "password".to_owned(),
/// ext_uris: None,
/// tls_files: None,
/// },
/// );
/// let config = EppClientConfig { registry };
///
/// // Create an instance of EppClient, passing the config and the registry you want to connect to
/// let mut client = match EppClient::new(&config, "registry_name").await {
/// Ok(client) => client,
/// Err(e) => panic!("Failed to create EppClient: {}", e)
/// };
///
/// let namestore_ext = NameStore::new("com");
///
/// // Create an DomainCheck instance
/// let domain_check = DomainCheck::<NameStore>::new(
/// vec!["eppdev-100.com", "eppdev-200.com"],
/// ).with_extension(namestore_ext);
///
/// // send it to the registry and receive a response of type EppDomainCheckResponse
/// let response = client.transact(domain_check, generate_client_tr_id(&client).as_str()).await.unwrap();
///
/// println!("{:?}", response);
///
/// client.logout().await.unwrap();
/// }
/// ```
impl NameStore {
/// Create a new RGP restore report request
pub fn new(subproduct: &str) -> NameStore {
NameStore {
xmlns: XMLNS.to_string(),
subproduct: subproduct.into(),
}
}
}
impl EppExtension for NameStore {
type Response = NameStore;
}
#[derive(Serialize, Deserialize, Debug, ElementName)]
#[element_name(name = "namestoreExt:namestoreExt")]
/// Type for EPP XML &lt;namestoreExt&gt; extension
pub struct NameStore {
/// XML namespace for the RGP restore extension
#[serde(rename = "xmlns:namestoreExt", alias = "xmlns")]
pub xmlns: String,
/// The object holding the list of domains to be checked
#[serde(rename = "namestoreExt:subProduct", alias = "subProduct")]
pub subproduct: StringValue,
}

View File

@ -135,6 +135,7 @@ pub mod domain {
} }
pub mod extensions { pub mod extensions {
pub mod namestore;
pub mod rgp; pub mod rgp;
} }