pub struct Client { /* private fields */ }Expand description
Client is the main handle for interacting with iroh-services. It communicates with
iroh-services entirely through an iroh endpoint, and is configured through a builder.
Client requires either an Ssh Key or ApiSecret
use iroh::{Endpoint, endpoint::presets};
use iroh_services::Client;
async fn build_client() -> anyhow::Result<()> {
let endpoint = Endpoint::bind(presets::N0).await?;
// needs IROH_SERVICES_API_SECRET set to an environment variable
// client will now push endpoint metrics to iroh-services.
let client = Client::builder(&endpoint)
.api_secret_from_str("MY_API_SECRET")?
.build()
.await;
Ok(())
}Implementations§
Source§impl Client
impl Client
pub fn builder(endpoint: &Endpoint) -> ClientBuilder
Sourcepub async fn name(&self) -> Result<Option<String>, Error>
pub async fn name(&self) -> Result<Option<String>, Error>
Read the current endpoint name from the local client.
Sourcepub async fn set_name(&self, name: impl Into<String>) -> Result<(), Error>
pub async fn set_name(&self, name: impl Into<String>) -> Result<(), Error>
Name the active endpoint cloud-side.
names can be any UTF-8 string, with a min length of 2 bytes, and maximum length of 128 bytes. name uniqueness is not enforced.
Sourcepub async fn push_metrics(&self) -> Result<(), Error>
pub async fn push_metrics(&self) -> Result<(), Error>
immediately send a single dump of metrics to iroh-services. It’s not necessary to call this function if you’re using a non-zero metrics interval, which will automatically propagate metrics on the set interval for you
Sourcepub async fn grant_capability(
&self,
remote_id: EndpointId,
caps: impl IntoIterator<Item = impl Into<Cap>>,
) -> Result<(), Error>
pub async fn grant_capability( &self, remote_id: EndpointId, caps: impl IntoIterator<Item = impl Into<Cap>>, ) -> Result<(), Error>
Grant capabilities to a remote endpoint. Creates a signed RCAN token and sends it to iroh-services for storage. The remote can then use this token when dialing back to authorize its requests.
Sourcepub async fn net_diagnostics(
&self,
send: bool,
) -> Result<DiagnosticsReport, Error>
pub async fn net_diagnostics( &self, send: bool, ) -> Result<DiagnosticsReport, Error>
run local network status diagnostics, optionally uploading the results