update doc and release 0.4
This commit is contained in:
parent
ca19e545fd
commit
20ab056dcf
|
@ -83,6 +83,7 @@ steps:
|
||||||
branch:
|
branch:
|
||||||
- 0.2
|
- 0.2
|
||||||
- 0.3
|
- 0.3
|
||||||
|
- 0.4
|
||||||
event: push
|
event: push
|
||||||
|
|
||||||
- name: notify
|
- name: notify
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
**/target
|
**/target
|
||||||
**/certs
|
**/certs
|
||||||
/config
|
/config
|
||||||
/epp-client/examples
|
/examples
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "epp-client"
|
name = "epp-client"
|
||||||
version = "0.3.1"
|
version = "0.4.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Ritesh Chitlangi <ritesh@ayravat.com>"]
|
authors = ["Ritesh Chitlangi <ritesh@ayravat.com>"]
|
||||||
|
|
84
README.md
84
README.md
|
@ -43,7 +43,7 @@ to eventually be RFC compliant with the EPP protocol.
|
||||||
Just add the following to your project's `Cargo.toml`
|
Just add the following to your project's `Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
epp-client = "0.3"
|
epp-client = "0.4"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Operation
|
## Operation
|
||||||
|
@ -51,90 +51,44 @@ epp-client = "0.3"
|
||||||
You can create a mut variable of type `EppClient` with the domain registry config.
|
You can create a mut variable of type `EppClient` with the domain registry config.
|
||||||
|
|
||||||
```rust
|
```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::EppClient;
|
||||||
use epp_client::domain::check::DomainCheck;
|
use epp_client::domain::DomainCheck;
|
||||||
use epp_client::common::NoExtension;
|
|
||||||
use epp_client::login::Login;
|
use epp_client::login::Login;
|
||||||
use epp_client::logout::Logout;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// Configure the client to connect to one of more registries
|
// Create an instance of EppClient
|
||||||
let mut registry: HashMap<String, RegistryConfig> = HashMap::new();
|
let host = "example.com";
|
||||||
registry.insert(
|
let addr = (host, 700).to_socket_addrs().unwrap().next().unwrap();
|
||||||
"registry_name".to_owned(),
|
let timeout = Duration::from_secs(5);
|
||||||
RegistryConfig {
|
let mut client = match EppClient::connect("registry_name".to_string(), addr, host, None, timeout).await {
|
||||||
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 {
|
|
||||||
Ok(client) => client,
|
Ok(client) => client,
|
||||||
Err(e) => panic!("Failed to create EppClient: {}", e)
|
Err(e) => panic!("Failed to create EppClient: {}", e)
|
||||||
};
|
};
|
||||||
|
|
||||||
let login = Login::<NoExtension>::new("username", "password", None);
|
let login = Login::new("username", "password", None);
|
||||||
client.transact(login, "transaction-id").await.unwrap();
|
client.transact(&login, "transaction-id").await.unwrap();
|
||||||
|
|
||||||
// Create an DomainCheck instance
|
// Execute an EPP Command against the registry with distinct request and response objects
|
||||||
let domain_check = DomainCheck::<NoExtension>::new(
|
let domain_check = DomainCheck { domains: &["eppdev.com", "eppdev.net"] };
|
||||||
vec!["eppdev-100.com", "eppdev-100.net"],
|
let response = client.transact(&domain_check, "transaction-id").await.unwrap();
|
||||||
);
|
|
||||||
|
|
||||||
// send it to the registry and receive a response of type EppDomainCheckResponse
|
response.res_data.unwrap().list
|
||||||
let response = client.transact(domain_check, "transaction-id").await.unwrap();
|
.iter()
|
||||||
|
.for_each(|chk| println!("Domain: {}, Available: {}", chk.id, chk.available));
|
||||||
println!("{:?}", response);
|
|
||||||
|
|
||||||
let logout = Logout::<NoExtension>::new();
|
|
||||||
client.transact(logout, "transaction-id").await.unwrap();
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The output would look similar to the following:
|
The output would look like this:
|
||||||
|
|
||||||
```
|
```text
|
||||||
Domain: eppdev.com, Available: 1
|
Domain: eppdev.com, Available: 1
|
||||||
Domain: eppdev.net, 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
|
## Request
|
||||||
|
|
||||||
Currently I don't have access to a registry's OT&E account to do extensive
|
Currently I don't have access to a registry's OT&E account to do extensive
|
||||||
|
|
38
src/lib.rs
38
src/lib.rs
|
@ -55,6 +55,44 @@
|
||||||
//!
|
//!
|
||||||
//! ## Operation
|
//! ## 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 client;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
|
|
Loading…
Reference in New Issue