pub struct AnsClient { /* private fields */ }Expand description
ANS Registry API client.
Provides methods for agent registration, certificate management, and agent discovery operations.
Implementations§
Source§impl AnsClient
impl AnsClient
Sourcepub fn builder() -> AnsClientBuilder
pub fn builder() -> AnsClientBuilder
Create a new builder for constructing a client.
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a client with default settings.
Uses https://api.godaddy.com as the base URL with no authentication.
Sourcepub async fn register_agent(
&self,
request: &AgentRegistrationRequest,
) -> Result<RegistrationPending>
pub async fn register_agent( &self, request: &AgentRegistrationRequest, ) -> Result<RegistrationPending>
Register a new agent.
Returns the pending registration details including required next steps for completing registration (DNS configuration, domain validation, etc.).
§Errors
ClientError::Conflictif the agent is already registeredClientError::InvalidRequestif the request is invalid
Sourcepub async fn get_agent(&self, agent_id: &str) -> Result<AgentDetails>
pub async fn get_agent(&self, agent_id: &str) -> Result<AgentDetails>
Sourcepub async fn search_agents(
&self,
criteria: &SearchCriteria,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<AgentSearchResponse>
pub async fn search_agents( &self, criteria: &SearchCriteria, limit: Option<u32>, offset: Option<u32>, ) -> Result<AgentSearchResponse>
Search for agents.
§Arguments
criteria- Search criteria (display name, host, version, protocol)limit- Maximum results to return (1-100, default 20)offset- Number of results to skip for pagination
Sourcepub async fn resolve_agent(
&self,
agent_host: &str,
version: &str,
) -> Result<AgentResolutionResponse>
pub async fn resolve_agent( &self, agent_host: &str, version: &str, ) -> Result<AgentResolutionResponse>
Resolve an ANS name to agent details.
§Arguments
agent_host- The agent’s host domainversion- Version pattern (“*” for any, or semver range like “^1.0.0”)
Sourcepub async fn verify_acme(&self, agent_id: &str) -> Result<AgentStatus>
pub async fn verify_acme(&self, agent_id: &str) -> Result<AgentStatus>
Trigger ACME domain validation.
Call this after configuring the ACME challenge (DNS or HTTP).
§Errors
ClientError::NotFoundif the agent doesn’t existClientError::InvalidRequestif validation fails
Sourcepub async fn verify_dns(&self, agent_id: &str) -> Result<AgentStatus>
pub async fn verify_dns(&self, agent_id: &str) -> Result<AgentStatus>
Verify DNS records are configured correctly.
Call this after configuring all required DNS records.
§Errors
ClientError::NotFoundif the agent doesn’t existClientError::InvalidRequestif DNS verification fails
Sourcepub async fn get_server_certificates(
&self,
agent_id: &str,
) -> Result<Vec<CertificateResponse>>
pub async fn get_server_certificates( &self, agent_id: &str, ) -> Result<Vec<CertificateResponse>>
Get server certificates for an agent.
Sourcepub async fn get_identity_certificates(
&self,
agent_id: &str,
) -> Result<Vec<CertificateResponse>>
pub async fn get_identity_certificates( &self, agent_id: &str, ) -> Result<Vec<CertificateResponse>>
Get identity certificates for an agent.
Sourcepub async fn submit_server_csr(
&self,
agent_id: &str,
csr_pem: &str,
) -> Result<CsrSubmissionResponse>
pub async fn submit_server_csr( &self, agent_id: &str, csr_pem: &str, ) -> Result<CsrSubmissionResponse>
Submit a server certificate CSR.
Sourcepub async fn submit_identity_csr(
&self,
agent_id: &str,
csr_pem: &str,
) -> Result<CsrSubmissionResponse>
pub async fn submit_identity_csr( &self, agent_id: &str, csr_pem: &str, ) -> Result<CsrSubmissionResponse>
Submit an identity certificate CSR.
Sourcepub async fn get_csr_status(
&self,
agent_id: &str,
csr_id: &str,
) -> Result<CsrStatusResponse>
pub async fn get_csr_status( &self, agent_id: &str, csr_id: &str, ) -> Result<CsrStatusResponse>
Get CSR status.
Sourcepub async fn revoke_agent(
&self,
agent_id: &str,
reason: RevocationReason,
comments: Option<&str>,
) -> Result<AgentRevocationResponse>
pub async fn revoke_agent( &self, agent_id: &str, reason: RevocationReason, comments: Option<&str>, ) -> Result<AgentRevocationResponse>
Revoke an agent.
This permanently revokes the agent’s certificates and marks the registration as revoked.
§Errors
ClientError::NotFoundif the agent doesn’t exist
Sourcepub async fn get_events(
&self,
limit: Option<u32>,
provider_id: Option<&str>,
last_log_id: Option<&str>,
) -> Result<EventPageResponse>
pub async fn get_events( &self, limit: Option<u32>, provider_id: Option<&str>, last_log_id: Option<&str>, ) -> Result<EventPageResponse>
Get paginated agent events.
This endpoint is used by Agent Host Providers (AHPs) to track agent registration events across the system.
§Arguments
limit- Maximum events to return (1-100)provider_id- Filter by provider ID (optional)last_log_id- Continuation token from previous response (for pagination)
§Example
use ans_client::AnsClient;
let client = AnsClient::builder()
.base_url("https://api.godaddy.com")
.api_key("key", "secret")
.build()?;
// Get first page
let page1 = client.get_events(Some(50), None, None).await?;
for event in &page1.items {
println!("{}: {} - {}", event.event_type, event.ans_name, event.agent_host);
}
// Get next page if available
if let Some(last_id) = page1.last_log_id {
let page2 = client.get_events(Some(50), None, Some(&last_id)).await?;
}