From 1b72565d36211699d8f9f9df49be5b7450256ce2 Mon Sep 17 00:00:00 2001 From: Daniel H <41769642+husseyd@users.noreply.github.com> Date: Thu, 26 Oct 2023 09:54:52 +1100 Subject: [PATCH] Align Google APIs URLs with Discovery docs per #541 (#542) Fixes #542 --- NEWS.md | 7 +++++++ R/bq-request.R | 4 ++-- R/gs-object.R | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index c250b970..5ec8e833 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,12 @@ # bigrquery (development version) +* Align Google APIs URLs to Google Cloud Discovery docs. This enables support for Private and Restricted Google APIs configurations. + (@husseyd, #541) + - `R/bq-request.R` + - Substitute `https://bigquery.googleapis.com` for `https://www.googleapis.com` + - `R/gs-object.R` + - Substitute `https://storage.googleapis.com` for `https://www.googleapis.com` + # bigrquery 1.4.2 * Sync up with the current release of gargle (1.4.0). Recently gargle diff --git a/R/bq-request.R b/R/bq-request.R index 133c9a90..93a9eb37 100644 --- a/R/bq-request.R +++ b/R/bq-request.R @@ -1,5 +1,5 @@ -base_url <- "https://www.googleapis.com/bigquery/v2/" -upload_url <- "https://www.googleapis.com/upload/bigquery/v2/" +base_url <- "https://bigquery.googleapis.com/bigquery/v2/" +upload_url <- "https://bigquery.googleapis.com/upload/bigquery/v2/" prepare_bq_query <- function(query) { api_key <- Sys.getenv("BIGRQUERY_API_KEY") diff --git a/R/gs-object.R b/R/gs-object.R index 99bdd73c..ec60f4c2 100644 --- a/R/gs-object.R +++ b/R/gs-object.R @@ -22,13 +22,13 @@ print.gs_object <- function(x, ...) { } gs_object_delete <- function(x, token = bq_token()) { - url <- glue_data(x, "https://www.googleapis.com/storage/v1/b/{bucket}/o/{object}") + url <- glue_data(x, "https://storage.googleapis.com/storage/v1/b/{bucket}/o/{object}") req <- httr::DELETE(url, token, httr::user_agent(bq_ua())) process_request(req) } gs_object_exists <- function(x, token = bq_token()) { - url <- glue_data(x, "https://www.googleapis.com/storage/v1/b/{bucket}/o/{object}") + url <- glue_data(x, "https://storage.googleapis.com/storage/v1/b/{bucket}/o/{object}") req <- httr::GET(url, token, httr::user_agent(bq_ua())) req$status_code != 404 }