update doc and release 0.4

This commit is contained in:
Ritesh Chitlangi 2022-07-26 14:49:37 +08:00
parent ca19e545fd
commit 20ab056dcf
5 changed files with 60 additions and 67 deletions

View File

@ -83,6 +83,7 @@ steps:
branch:
- 0.2
- 0.3
- 0.4
event: push
- name: notify

2
.gitignore vendored
View File

@ -2,5 +2,5 @@
**/target
**/certs
/config
/epp-client/examples
/examples
Cargo.lock

View File

@ -1,6 +1,6 @@
[package]
name = "epp-client"
version = "0.3.1"
version = "0.4.0"
edition = "2018"
license = "MIT"
authors = ["Ritesh Chitlangi <ritesh@ayravat.com>"]

View File

@ -43,7 +43,7 @@ to eventually be RFC compliant with the EPP protocol.
Just add the following to your project's `Cargo.toml`
```toml
epp-client = "0.3"
epp-client = "0.4"
```
## Operation
@ -51,90 +51,44 @@ epp-client = "0.3"
You can create a mut variable of type `EppClient` with the domain registry config.
```rust
use std::collections::HashMap;
use std::net::ToSocketAddrs;
use std::time::Duration;
use epp_client::config::{EppClientConfig, RegistryConfig};
use epp_client::EppClient;
use epp_client::domain::check::DomainCheck;
use epp_client::common::NoExtension;
use epp_client::domain::DomainCheck;
use epp_client::login::Login;
use epp_client::logout::Logout;
#[tokio::main]
async fn main() {
// Configure the client to connect to one of more registries
let mut registry: HashMap<String, RegistryConfig> = HashMap::new();
registry.insert(
"registry_name".to_owned(),
RegistryConfig {
host: "example.com".to_owned(),
port: 700,
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 {
// Create an instance of EppClient
let host = "example.com";
let addr = (host, 700).to_socket_addrs().unwrap().next().unwrap();
let timeout = Duration::from_secs(5);
let mut client = match EppClient::connect("registry_name".to_string(), addr, host, None, timeout).await {
Ok(client) => client,
Err(e) => panic!("Failed to create EppClient: {}", e)
};
let login = Login::<NoExtension>::new("username", "password", None);
client.transact(login, "transaction-id").await.unwrap();
let login = Login::new("username", "password", None);
client.transact(&login, "transaction-id").await.unwrap();
// Create an DomainCheck instance
let domain_check = DomainCheck::<NoExtension>::new(
vec!["eppdev-100.com", "eppdev-100.net"],
);
// Execute an EPP Command against the registry with distinct request and response objects
let domain_check = DomainCheck { domains: &["eppdev.com", "eppdev.net"] };
let response = client.transact(&domain_check, "transaction-id").await.unwrap();
// send it to the registry and receive a response of type EppDomainCheckResponse
let response = client.transact(domain_check, "transaction-id").await.unwrap();
println!("{:?}", response);
let logout = Logout::<NoExtension>::new();
client.transact(logout, "transaction-id").await.unwrap();
response.res_data.unwrap().list
.iter()
.for_each(|chk| println!("Domain: {}, Available: {}", chk.id, chk.available));
}
```
The output would look similar to the following:
The output would look like this:
```
```text
Domain: eppdev.com, Available: 1
Domain: eppdev.net, Available: 1
```
You may also choose to store your configuration in something like a toml file:
```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'
```
```rust
use epp_client::config::{EppClientConfig};
#[tokio::main]
async fn main() {
// parse EppClientConfig from toml file
let config_path = Path::new("../secrets/epp-client.toml");
let config: EppClientConfig =
toml::from_str(&fs::read_to_string(config_path).await.unwrap()).unwrap();
}
```
## Request
Currently I don't have access to a registry's OT&E account to do extensive

View File

@ -55,6 +55,44 @@
//!
//! ## Operation
//!
//! ```no_run
//! use std::net::ToSocketAddrs;
//! use std::time::Duration;
//!
//! use epp_client::EppClient;
//! use epp_client::domain::DomainCheck;
//! use epp_client::login::Login;
//!
//! #[tokio::main]
//! async fn main() {
//! // Create an instance of EppClient
//! let host = "example.com";
//! let addr = (host, 700).to_socket_addrs().unwrap().next().unwrap();
//! let timeout = Duration::from_secs(5);
//! let mut client = match EppClient::connect("registry_name".to_string(), addr, host, None, timeout).await {
//! Ok(client) => client,
//! Err(e) => panic!("Failed to create EppClient: {}", e)
//! };
//!
//! let login = Login::new("username", "password", None);
//! client.transact(&login, "transaction-id").await.unwrap();
//!
//! // Execute an EPP Command against the registry with distinct request and response objects
//! let domain_check = DomainCheck { domains: &["eppdev.com", "eppdev.net"] };
//! let response = client.transact(&domain_check, "transaction-id").await.unwrap();
//!
//! response.res_data.unwrap().list
//! .iter()
//! .for_each(|chk| println!("Domain: {}, Available: {}", chk.id, chk.available));
//! }
//! ```
//!
//! The output would look similar to the following
//!
//! ```text
//! Domain: eppdev.com, Available: 1
//! Domain: eppdev.net, Available: 1
//! ```
pub mod client;
pub mod common;