pub struct Client { /* private fields */ }
Expand description
The client is the entrypoint of the whole SDK.
You can create it using Client::builder
or Client::new
.
§Examples
use axiom_rs::{Client, Error};
fn main() -> Result<(), Error> {
// Create a new client and get the token and (if necesary) org id
// from the environment variables AXIOM_TOKEN and AXIOM_ORG_ID.
let client = Client::new()?;
// Set all available options. Unset options fall back to environment
// variables.
let client = Client::builder()
.with_token("my-token")
.with_org_id("my-org-id")
.build()?;
Ok(())
}
Implementations§
Source§impl Client
impl Client
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new client. If you want to configure it, use Client::builder
.
§Errors
If the client can not be created
Sourcepub fn annotations(&self) -> Client<'_>
pub fn annotations(&self) -> Client<'_>
Annotations API
Sourcepub async fn query<S, O>(&self, apl: &S, opts: O) -> Result<QueryResult>
pub async fn query<S, O>(&self, apl: &S, opts: O) -> Result<QueryResult>
Executes the given query specified using the Axiom Processing Language (APL). To learn more about APL, see the APL documentation at https://www.axiom.co/docs/apl/introduction.
§Errors
Returns an error if the HTTP request or JSON deserializing fails.
Sourcepub async fn ingest<N, I, E>(
&self,
dataset_name: N,
events: I,
) -> Result<IngestStatus>
pub async fn ingest<N, I, E>( &self, dataset_name: N, events: I, ) -> Result<IngestStatus>
Ingest events into the dataset identified by its id. Restrictions for field names (JSON object keys) can be reviewed here: https://www.axiom.co/docs/usage/field-restrictions.
§Errors
Returns an error if the events cannot be serialized or if the HTTP request or JSON deserializing fails.
Sourcepub async fn ingest_bytes<N, P>(
&self,
dataset_name: N,
payload: P,
content_type: ContentType,
content_encoding: ContentEncoding,
) -> Result<IngestStatus>
pub async fn ingest_bytes<N, P>( &self, dataset_name: N, payload: P, content_type: ContentType, content_encoding: ContentEncoding, ) -> Result<IngestStatus>
Ingest data into the dataset identified by its id. Restrictions for field names (JSON object keys) can be reviewed here: https://www.axiom.co/docs/usage/field-restrictions.
§Errors
Returns an error if the HTTP request or JSON deserializing fails.
Sourcepub async fn ingest_bytes_opt<N, P>(
&self,
dataset_name: N,
payload: P,
content_type: ContentType,
content_encoding: ContentEncoding,
request_options: RequestOptions,
) -> Result<IngestStatus>
pub async fn ingest_bytes_opt<N, P>( &self, dataset_name: N, payload: P, content_type: ContentType, content_encoding: ContentEncoding, request_options: RequestOptions, ) -> Result<IngestStatus>
Like ingest_bytes
, but takes a RequestOptions
, which allows you to
customize your request further.
Note that any content-type and content-type headers in RequestOptions
will be overwritten by the given arguments.
§Errors
Returns an error if the HTTP request or JSON deserializing fails.
Sourcepub async fn ingest_stream<N, S, E>(
&self,
dataset_name: N,
stream: S,
) -> Result<IngestStatus>
pub async fn ingest_stream<N, S, E>( &self, dataset_name: N, stream: S, ) -> Result<IngestStatus>
Ingest a stream of events into a dataset. Events will be ingested in chunks of 1000 items. If ingestion of a chunk fails, it will be retried with a backoff. Restrictions for field names (JSON object keys) can be reviewed here: https://www.axiom.co/docs/usage/field-restrictions.
§Errors
Returns an error if the HTTP request or JSON deserializing fails.
Sourcepub async fn try_ingest_stream<N, S, I, E>(
&self,
dataset_name: N,
stream: S,
) -> Result<IngestStatus>
pub async fn try_ingest_stream<N, S, I, E>( &self, dataset_name: N, stream: S, ) -> Result<IngestStatus>
Like Client::ingest_stream
, but takes a stream that contains results.
§Errors
Returns an error if the HTTP request or JSON deserializing fails.