From 4d3315166e505c1b594cc99ce05997220613752b Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Thu, 12 Jan 2023 13:49:39 +0100 Subject: [PATCH 1/2] Update URL to the new API url --- .github/workflows/ci.yaml | 2 +- src/client.rs | 10 +++++----- src/http.rs | 11 ++++------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 35bef5d..847eaa9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 }} diff --git a/src/client.rs b/src/client.rs index 7505106..da16073 100644 --- a/src/client.rs +++ b/src/client.rs @@ -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); } diff --git a/src/http.rs b/src/http.rs index 0f99b35..58b4799 100644 --- a/src/http.rs +++ b/src/http.rs @@ -42,10 +42,7 @@ impl Client { T: Into, O: Into>, { - 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") From 215361e1b50d8bef5d1444a39b5cef39ea397df7 Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Thu, 12 Jan 2023 16:55:11 +0100 Subject: [PATCH 2/2] Fix build badge See https://github.com/badges/shields/issues/8671 Fixes DX-430 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ea7276..5e971a9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@
[![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)