Skip to content

Commit

Permalink
Merge pull request #40 from axiomhq/arne/dx-245-prepare-axiom-rust-fo…
Browse files Browse the repository at this point in the history
…r-split-of-cloud

Update URL to the new API url
lukasmalkmus authored Jan 12, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 392b4e0 + 215361e commit 6fc280e
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ jobs:
- name: Run cargo test
uses: actions-rs/cargo@v1
env:
AXIOM_URL: ${{ secrets.TESTING_DEV_APP_URL }}
AXIOM_URL: ${{ secrets.TESTING_DEV_API_URL }}
AXIOM_TOKEN: ${{ secrets.TESTING_DEV_TOKEN }}
AXIOM_ORG_ID: ${{ secrets.TESTING_DEV_ORG_ID }}
AXIOM_DATASET_SUFFIX: ${{ github.run_id }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
<div align="center">

[![docs.rs](https://docs.rs/axiom-rs/badge.svg)](https://docs.rs/axiom-rs/)
[![build](https://img.shields.io/github/workflow/status/axiomhq/axiom-rs/CI?ghcache=unused)](https://github.com/axiomhq/axiom-rs/actions?query=workflow%3ACI)
[![build](https://img.shields.io/github/actions/workflow/status/axiomhq/axiom-rs/ci.yaml?branch=main&ghcache=unused)](https://github.com/axiomhq/axiom-rs/actions?query=workflow%3ACI)
[![crates.io](https://img.shields.io/crates/v/axiom-rs.svg)](https://crates.io/crates/axiom-rs)
[![License](https://img.shields.io/crates/l/axiom-rs)](LICENSE-APACHE)

10 changes: 5 additions & 5 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@ use crate::{
is_personal_token, users,
};

/// Cloud URL is the URL for Axiom Cloud.
static CLOUD_URL: &str = "https://cloud.axiom.co";
/// API URL is the URL for the Axiom Cloud API.
static API_URL: &str = "https://api.axiom.co";

/// The client is the entrypoint of the whole SDK.
///
@@ -71,7 +71,7 @@ impl Client {
Builder::new()
}

/// Get the url (cloned).
/// Get the API url (cloned).
#[doc(hidden)]
pub fn url(&self) -> String {
self.url.clone()
@@ -351,7 +351,7 @@ impl Builder {
url = env::var("AXIOM_URL").unwrap_or_default();
}
if url.is_empty() {
url = CLOUD_URL.to_string();
url = API_URL.to_string();
}

let mut org_id = self.org_id.unwrap_or_default();
@@ -360,7 +360,7 @@ impl Builder {
};

// On Cloud you need an Org ID for Personal Tokens.
if url == CLOUD_URL && org_id.is_empty() && is_personal_token(&token) {
if url == API_URL && org_id.is_empty() && is_personal_token(&token) {
return Err(Error::MissingOrgId);
}

11 changes: 4 additions & 7 deletions src/http.rs
Original file line number Diff line number Diff line change
@@ -42,10 +42,7 @@ impl Client {
T: Into<String>,
O: Into<Option<String>>,
{
let base_url = Url::parse(base_url.as_ref())
.map_err(Error::InvalidUrl)?
.join("api/")
.map_err(Error::InvalidUrl)?;
let base_url = Url::parse(base_url.as_ref()).map_err(Error::InvalidUrl)?;
let token = token.into();

let mut default_headers = header::HeaderMap::new();
@@ -291,7 +288,7 @@ mod test {

let server = MockServer::start();
let rate_mock = server.mock(|when, then| {
when.method(POST).path("/api/v1/datasets/test/ingest");
when.method(POST).path("/v1/datasets/test/ingest");
then.status(429)
.json_body(json!({ "message": "rate limit exceeded" }))
.header(limits::HEADER_INGEST_LIMIT, "42")
@@ -328,7 +325,7 @@ mod test {

let server = MockServer::start();
let rate_mock = server.mock(|when, then| {
when.method(POST).path("/api/v1/datasets/_apl");
when.method(POST).path("/v1/datasets/_apl");
then.status(429)
.json_body(json!({ "message": "rate limit exceeded" }))
.header(limits::HEADER_QUERY_LIMIT, "42")
@@ -365,7 +362,7 @@ mod test {

let server = MockServer::start();
let rate_mock = server.mock(|when, then| {
when.method(GET).path("/api/v1/datasets");
when.method(GET).path("/v1/datasets");
then.status(429)
.json_body(json!({ "message": "rate limit exceeded" }))
.header(limits::HEADER_RATE_SCOPE, "user")

0 comments on commit 6fc280e

Please sign in to comment.