Skip to main content

ans_client/
lib.rs

1#![warn(missing_docs)]
2
3//! # ANS API Client
4//!
5//! This crate provides a client for interacting with the ANS (Agent Name Service) API
6//! for agent registration, certificate management, and discovery operations.
7//!
8//! ## Features
9//!
10//! - Agent registration and renewal
11//! - Certificate signing request submission
12//! - Agent search and resolution
13//! - Domain validation (ACME, DNS)
14//! - Agent revocation
15//!
16//! ## Quick Start
17//!
18//! ```rust,no_run
19//! use ans_client::{AnsClient, models::*};
20//!
21//! #[tokio::main]
22//! async fn main() -> ans_client::Result<()> {
23//!     // Create a client with JWT authentication
24//!     let client = AnsClient::builder()
25//!         .base_url("https://api.godaddy.com")
26//!         .jwt("your-jwt-token")
27//!         .build()?;
28//!
29//!     // Search for agents
30//!     let mut criteria = SearchCriteria::default();
31//!     criteria.agent_host = Some("example.com".into());
32//!     let results = client.search_agents(&criteria, Some(10), None).await?;
33//!
34//!     for agent in results.agents {
35//!         println!("{}: {}", agent.ans_name, agent.agent_display_name);
36//!     }
37//!
38//!     Ok(())
39//! }
40//! ```
41//!
42//! ## Authentication
43//!
44//! The ANS API supports two authentication methods:
45//!
46//! - **JWT**: For endpoints at `api.{env}-godaddy.com`
47//!   ```rust
48//!   # use ans_client::AnsClient;
49//!   let client = AnsClient::builder()
50//!       .jwt("your-jwt-token")
51//!       .build();
52//!   ```
53//!
54//! - **API Key**: For public gateway (`api.godaddy.com`)
55//!   ```rust
56//!   # use ans_client::AnsClient;
57//!   let client = AnsClient::builder()
58//!       .api_key("your-key", "your-secret")
59//!       .build();
60//!   ```
61//!
62//! ## Registration Flow
63//!
64//! Agent registration is a multi-step process:
65//!
66//! 1. Submit registration request with CSRs
67//! 2. Configure ACME challenge (DNS-01 or HTTP-01)
68//! 3. Call `verify_acme()` to validate domain ownership
69//! 4. Configure required DNS records
70//! 5. Call `verify_dns()` to complete registration
71//!
72//! ```rust,no_run
73//! # use ans_client::{AnsClient, models::*};
74//! # async fn example() -> ans_client::Result<()> {
75//! let client = AnsClient::builder()
76//!     .base_url("https://api.godaddy.com")
77//!     .jwt("token")
78//!     .build()?;
79//!
80//! // Step 1: Register
81//! let endpoint = AgentEndpoint::new("https://agent.example.com/mcp", Protocol::Mcp)
82//!     .with_transports(vec![Transport::StreamableHttp]);
83//!
84//! let request = AgentRegistrationRequest::new(
85//!     "my-agent",
86//!     "agent.example.com",
87//!     "1.0.0",
88//!     "-----BEGIN CERTIFICATE REQUEST-----...",
89//!     vec![endpoint],
90//! )
91//! .with_server_csr_pem("-----BEGIN CERTIFICATE REQUEST-----...");
92//!
93//! let pending = client.register_agent(&request).await?;
94//! let agent_id = pending.agent_id.expect("agent_id");
95//!
96//! // Step 2-3: Configure challenge, then verify
97//! // ... configure DNS or HTTP challenge ...
98//! let status = client.verify_acme(&agent_id).await?;
99//!
100//! // Step 4-5: Configure DNS records, then verify
101//! // ... configure DNS records from pending.dns_records ...
102//! let status = client.verify_dns(&agent_id).await?;
103//! # Ok(())
104//! # }
105//! ```
106
107pub mod client;
108pub mod error;
109pub mod models;
110
111pub use client::{AnsClient, AnsClientBuilder, Auth};
112pub use error::{ClientError, HttpError, Result};
113
114// Re-export types from ans-types for convenience
115pub use ans_types::{Fqdn, Version};