diff --git a/epp-client/src/config.rs b/epp-client/src/config.rs index eee867d..8227940 100644 --- a/epp-client/src/config.rs +++ b/epp-client/src/config.rs @@ -1,38 +1,31 @@ -//! Config load module +//! Config //! -//! Loads the configuration and credentials for each registry connection from -//! the `$XDG_CONFIG_HOME/epp-client/epp-client.toml` file -//! -//! ## Usage -//! -//! The config is automatically loaded when the module is initialized -//! and is available through the `epp_client::config::CONFIG` variable -//! -//! ## Sample config -//! -//! ```toml -//! [registry.verisign] -//! host = 'epp.verisign-grs.com' -//! port = 700 -//! username = 'username' -//! password = 'password' -//! # service extensions -//! ext_uris = [] -//! -//! [registry.hexonet.tls_files] -//! # the full client certificate chain in PEM format -//! cert_chain = '/path/to/certificate/chain/pemfile' -//! # the RSA private key for your certificate -//! key = '/path/to/private/key/pemfile' -//! ``` +//! This module contains the connection configuration for the EPP client. //! //! ## Example //! -//! ```rust -//! use epp_client::config::CONFIG; +//! ```no_run +//! use std::collections::HashMap; +//! +//! use epp_client::config::{EppClientConfig, EppClientConnection}; +//! +//! // Create a config +//! let mut registry: HashMap = HashMap::new(); +//! registry.insert( +//! "registry_name".to_owned(), +//! EppClientConnection { +//! 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 }; //! //! // Get configuration for the relevant registry section -//! let registry = CONFIG.registry("verisign").unwrap(); +//! let registry = config.registry("verisign").unwrap(); //! //! // Get EPP host name and port no. //! let remote = registry.connection_details(); diff --git a/epp-client/src/connection/client.rs b/epp-client/src/connection/client.rs index c24b857..ba1a19e 100644 --- a/epp-client/src/connection/client.rs +++ b/epp-client/src/connection/client.rs @@ -2,28 +2,47 @@ //! //! ## Example //! -//! ```rust +//! ```no_run +//! use std::collections::HashMap; +//! +//! use epp_client::config::{EppClientConfig, EppClientConnection}; //! use epp_client::EppClient; //! use epp_client::epp::{EppDomainCheck, EppDomainCheckResponse}; //! use epp_client::epp::generate_client_tr_id; //! //! #[tokio::main] //! async fn main() { -//! // Create an instance of EppClient, specifying the name of the registry as in -//! // the config file -//! let mut client = match EppClient::new("verisign").await { -//! Ok(client) => client, -//! Err(e) => panic!("Failed to create EppClient: {}", e) -//! }; //! -//! // Make a EPP Hello call to the registry -//! let greeting = client.hello().await.unwrap(); -//! println!("{:?}", greeting); +//! // Create a config +//! let mut registry: HashMap = HashMap::new(); +//! registry.insert( +//! "registry_name".to_owned(), +//! EppClientConnection { +//! 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) +//! }; +//! +//! // Make a EPP Hello call to the registry +//! let greeting = client.hello().await.unwrap(); +//! println!("{:?}", greeting); +//! +//! // Execute an EPP Command against the registry with distinct request and response objects +//! let domain_check = EppDomainCheck::new(vec!["eppdev.com", "eppdev.net"], generate_client_tr_id(&client).as_str()); +//! let response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap(); +//! println!("{:?}", response); //! -//! // Execute an EPP Command against the registry with distinct request and response objects -//! let domain_check = EppDomainCheck::new(vec!["eppdev.com", "eppdev.net"], generate_client_tr_id(&client).as_str()); -//! let response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap(); -//! println!("{:?}", response); //! } //! ``` diff --git a/epp-client/src/epp/request/contact/check.rs b/epp-client/src/epp/request/contact/check.rs index 5d8841c..053503f 100644 --- a/epp-client/src/epp/request/contact/check.rs +++ b/epp-client/src/epp/request/contact/check.rs @@ -1,5 +1,4 @@ -//! Types for EPP contact check request - +/// Types for EPP contact check request use epp_client_macros::*; use crate::epp::object::{ElementName, EppObject, StringValue, StringValueTrait}; @@ -11,16 +10,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```rust +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppContactCheck, EppContactCheckResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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 +/// let mut client = match EppClient::new(&config, "registry_name").await { /// Ok(client) => client, /// Err(e) => panic!("Failed to create EppClient: {}", e) /// }; diff --git a/epp-client/src/epp/request/contact/create.rs b/epp-client/src/epp/request/contact/create.rs index 4129571..0b35bc2 100644 --- a/epp-client/src/epp/request/contact/create.rs +++ b/epp-client/src/epp/request/contact/create.rs @@ -12,7 +12,10 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::object::data::{Address, Phone, PostalInfo}; /// use epp_client::epp::{EppContactCreate, EppContactCreateResponse}; @@ -20,9 +23,23 @@ use serde::{Deserialize, Serialize}; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/contact/delete.rs b/epp-client/src/epp/request/contact/delete.rs index f633d60..5c68107 100644 --- a/epp-client/src/epp/request/contact/delete.rs +++ b/epp-client/src/epp/request/contact/delete.rs @@ -11,16 +11,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppContactDelete, EppContactDeleteResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/contact/info.rs b/epp-client/src/epp/request/contact/info.rs index 49314b3..52055f9 100644 --- a/epp-client/src/epp/request/contact/info.rs +++ b/epp-client/src/epp/request/contact/info.rs @@ -12,16 +12,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppContactInfo, EppContactInfoResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/contact/update.rs b/epp-client/src/epp/request/contact/update.rs index f8935c1..59afb46 100644 --- a/epp-client/src/epp/request/contact/update.rs +++ b/epp-client/src/epp/request/contact/update.rs @@ -14,16 +14,34 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppContactUpdate, EppContactUpdateResponse}; /// use epp_client::epp::generate_client_tr_id; +/// use epp_client::epp::object::data::ContactStatus; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/domain/check.rs b/epp-client/src/epp/request/domain/check.rs index 6e3acc4..4ed1e25 100644 --- a/epp-client/src/epp/request/domain/check.rs +++ b/epp-client/src/epp/request/domain/check.rs @@ -11,16 +11,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```rust +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainCheck, EppDomainCheckResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/domain/create.rs b/epp-client/src/epp/request/domain/create.rs index 2fc92b8..7a4bee1 100644 --- a/epp-client/src/epp/request/domain/create.rs +++ b/epp-client/src/epp/request/domain/create.rs @@ -15,7 +15,10 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::object::data::DomainContact; /// use epp_client::epp::{EppDomainCreate, EppDomainCreateResponse}; @@ -23,9 +26,23 @@ use serde::{Deserialize, Serialize}; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/domain/delete.rs b/epp-client/src/epp/request/domain/delete.rs index 2163e94..64a5117 100644 --- a/epp-client/src/epp/request/domain/delete.rs +++ b/epp-client/src/epp/request/domain/delete.rs @@ -11,16 +11,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainDelete, EppDomainDeleteResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/domain/info.rs b/epp-client/src/epp/request/domain/info.rs index 77c81a2..916ed30 100644 --- a/epp-client/src/epp/request/domain/info.rs +++ b/epp-client/src/epp/request/domain/info.rs @@ -11,16 +11,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainInfo, EppDomainInfoResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/domain/renew.rs b/epp-client/src/epp/request/domain/renew.rs index bc637d3..52d7cbe 100644 --- a/epp-client/src/epp/request/domain/renew.rs +++ b/epp-client/src/epp/request/domain/renew.rs @@ -13,17 +13,35 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// /// use chrono::NaiveDate; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainRenew, EppDomainRenewResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/domain/rgp/report.rs b/epp-client/src/epp/request/domain/rgp/report.rs index 3c5c5df..c888a7e 100644 --- a/epp-client/src/epp/request/domain/rgp/report.rs +++ b/epp-client/src/epp/request/domain/rgp/report.rs @@ -16,7 +16,10 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainRgpRestoreReport, EppDomainRgpRestoreReportResponse}; /// use epp_client::epp::generate_client_tr_id; @@ -25,9 +28,23 @@ use serde::{Deserialize, Serialize}; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/domain/rgp/request.rs b/epp-client/src/epp/request/domain/rgp/request.rs index 4d3335e..febd2ef 100644 --- a/epp-client/src/epp/request/domain/rgp/request.rs +++ b/epp-client/src/epp/request/domain/rgp/request.rs @@ -15,16 +15,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainRgpRestoreRequest, EppDomainRgpRestoreRequestResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/domain/transfer.rs b/epp-client/src/epp/request/domain/transfer.rs index 1d8e226..3c63087 100644 --- a/epp-client/src/epp/request/domain/transfer.rs +++ b/epp-client/src/epp/request/domain/transfer.rs @@ -12,16 +12,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainTransferRequest, EppDomainTransferRequestResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; @@ -43,16 +60,33 @@ pub type EppDomainTransferRequest = EppObject>; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainTransferApprove, EppDomainTransferApproveResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; @@ -74,16 +108,33 @@ pub type EppDomainTransferApprove = EppObject>; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainTransferReject, EppDomainTransferRejectResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; @@ -105,16 +156,33 @@ pub type EppDomainTransferReject = EppObject>; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainTransferCancel, EppDomainTransferCancelResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; @@ -136,16 +204,33 @@ pub type EppDomainTransferCancel = EppObject>; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppDomainTransferQuery, EppDomainTransferQueryResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/domain/update.rs b/epp-client/src/epp/request/domain/update.rs index 16e7e53..c16bd04 100644 --- a/epp-client/src/epp/request/domain/update.rs +++ b/epp-client/src/epp/request/domain/update.rs @@ -13,7 +13,10 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::object::data::{DomainStatus, DomainContact}; /// use epp_client::epp::{EppDomainUpdate, EppDomainUpdateResponse, DomainAddRemove}; @@ -21,9 +24,23 @@ use serde::{Deserialize, Serialize}; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/host/check.rs b/epp-client/src/epp/request/host/check.rs index 7a3116b..c0917c8 100644 --- a/epp-client/src/epp/request/host/check.rs +++ b/epp-client/src/epp/request/host/check.rs @@ -11,16 +11,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```rust +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppHostCheck, EppHostCheckResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/host/create.rs b/epp-client/src/epp/request/host/create.rs index a117242..e16fadc 100644 --- a/epp-client/src/epp/request/host/create.rs +++ b/epp-client/src/epp/request/host/create.rs @@ -12,7 +12,10 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::object::data::HostAddr; /// use epp_client::epp::{EppHostCreate, EppHostCreateResponse}; @@ -20,9 +23,23 @@ use serde::{Deserialize, Serialize}; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/host/delete.rs b/epp-client/src/epp/request/host/delete.rs index c196cc5..bda9d45 100644 --- a/epp-client/src/epp/request/host/delete.rs +++ b/epp-client/src/epp/request/host/delete.rs @@ -11,16 +11,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppHostDelete, EppHostDeleteResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/host/info.rs b/epp-client/src/epp/request/host/info.rs index aad3720..07ef154 100644 --- a/epp-client/src/epp/request/host/info.rs +++ b/epp-client/src/epp/request/host/info.rs @@ -11,16 +11,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppHostInfo, EppHostInfoResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/host/update.rs b/epp-client/src/epp/request/host/update.rs index 981d221..ff59e2c 100644 --- a/epp-client/src/epp/request/host/update.rs +++ b/epp-client/src/epp/request/host/update.rs @@ -12,7 +12,10 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::object::StringValueTrait; /// use epp_client::epp::object::data::{HostAddr, HostStatus}; @@ -21,9 +24,23 @@ use serde::{Deserialize, Serialize}; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/message/ack.rs b/epp-client/src/epp/request/message/ack.rs index 9094259..a999519 100644 --- a/epp-client/src/epp/request/message/ack.rs +++ b/epp-client/src/epp/request/message/ack.rs @@ -9,16 +9,33 @@ use serde::{Deserialize, Serialize}; /// Type that represents the <epp> request for registry command /// ## Usage /// -/// ```ignore +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppMessageAck, EppMessageAckResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/epp/request/message/poll.rs b/epp-client/src/epp/request/message/poll.rs index 3718b70..0dde150 100644 --- a/epp-client/src/epp/request/message/poll.rs +++ b/epp-client/src/epp/request/message/poll.rs @@ -10,16 +10,33 @@ use serde::{Deserialize, Serialize}; /// /// ## Usage /// -/// ```rust +/// ```no_run +/// use std::collections::HashMap; +/// +/// use epp_client::config::{EppClientConfig, EppClientConnection}; /// use epp_client::EppClient; /// use epp_client::epp::{EppMessagePoll, EppMessagePollResponse}; /// use epp_client::epp::generate_client_tr_id; /// /// #[tokio::main] /// async fn main() { -/// // Create an instance of EppClient, specifying the name of the registry as in -/// // the config file -/// let mut client = match EppClient::new("verisign").await { +/// // Create a config +/// let mut registry: HashMap = HashMap::new(); +/// registry.insert( +/// "registry_name".to_owned(), +/// EppClientConnection { +/// 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) /// }; diff --git a/epp-client/src/lib.rs b/epp-client/src/lib.rs index 3f4d60f..608db87 100644 --- a/epp-client/src/lib.rs +++ b/epp-client/src/lib.rs @@ -33,68 +33,63 @@ //! - RGP Restore Request - [`EppDomainRgpRestoreRequest`](epp/request/domain/rgp/request/type.EppDomainRgpRestoreRequest.html) //! - RGP Restore Report - [`EppDomainRgpRestoreReport`](epp/request/domain/rgp/report/type.EppDomainRgpRestoreReport.html) //! -//! ## Prerequisites -//! -//! To use the library, you must have an `epp-client/epp-client.toml` config file with the relevant registry -//! credentials in your default user configuration directory on your OS. For Linux, this is the `XDG user directory`, -//! usually located at `$HOME/.config` or defined by the `XDG_CONFIG_HOME` environment variable. -//! -//! An example config looks like this: -//! -//! ```toml -//! [registry.verisign] -//! host = 'epp.verisign-grs.com' -//! port = 700 -//! username = 'username' -//! password = 'password' -//! # service extensions -//! ext_uris = [] -//! -//! [registry.verisign.tls_files] -//! # the full client certificate chain in PEM format -//! cert_chain = '/path/to/certificate/chain/pemfile' -//! # the RSA private key for your certificate -//! key = '/path/to/private/key/pemfile' -//! ``` -//! //! ## Operation //! //! Once the config is set correctly, you can create a mut variable of type [`EppClient`] to transact //! with the domain registry //! -//! ```rust +//! ```no_run +//! use std::collections::HashMap; +//! +//! use epp_client::config::{EppClientConfig, EppClientConnection}; //! use epp_client::EppClient; //! use epp_client::epp::{EppDomainCheck, EppDomainCheckResponse}; //! use epp_client::epp::generate_client_tr_id; //! //! #[tokio::main] //! async fn main() { -//! // Create an instance of EppClient, specifying the name of the registry as in -//! // the config file -//! let mut client = match EppClient::new("verisign").await { -//! Ok(client) => client, -//! Err(e) => panic!("Failed to create EppClient: {}", e) -//! }; //! -//! // Make a domain check call, which returns an object of type EppDomainCheckResponse -//! // that contains the result of the call -//! let domain_check = EppDomainCheck::new( -//! vec!["eppdev.com", "eppdev.net"], -//! generate_client_tr_id(&client).as_str() -//! ); +//! // Create a config +//! let mut registry: HashMap = HashMap::new(); +//! registry.insert( +//! "registry_name".to_owned(), +//! EppClientConnection { +//! 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 }; //! -//! let response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap(); +//! // 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) +//! }; +//! +//! // Make a domain check call, which returns an object of type EppDomainCheckResponse +//! // that contains the result of the call +//! let domain_check = EppDomainCheck::new( +//! vec!["eppdev.com", "eppdev.net"], +//! generate_client_tr_id(&client).as_str() +//! ); +//! +//! let response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap(); +//! +//! // print the availability results +//! response.data.res_data.unwrap().check_data.domain_list +//! .iter() +//! .for_each(|chk| println!("Domain: {}, Available: {}", chk.domain.name, chk.domain.available)); //! -//! // print the availability results -//! response.data.res_data.unwrap().check_data.domain_list -//! .iter() -//! .for_each(|chk| println!("Domain: {}, Available: {}", chk.domain.name, chk.domain.available)); //! } //! ``` //! //! The output would look similar to the following //! -//! ``` +//! ```text //! Domain: eppdev.com, Available: 1 //! Domain: eppdev.net, Available: 1 //! ```