From 6f7f6fd422b0f3d77ce9381d02c7a8d5014fb88f Mon Sep 17 00:00:00 2001 From: Laura A DeCicco Date: Thu, 31 Oct 2024 15:28:01 -0500 Subject: [PATCH 1/9] Custom UAs not actually getting in user agent. --- R/getWebServiceData.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/getWebServiceData.R b/R/getWebServiceData.R index 8aa6cd9a..68c2e78e 100644 --- a/R/getWebServiceData.R +++ b/R/getWebServiceData.R @@ -137,7 +137,7 @@ default_ua <- function() { ua <- paste0(names(versions), "/", versions, collapse = " ") - if ("UA.dataRetrieval" %in% names(options)) { + if ("UA.dataRetrieval" %in% names(options())) { ua <- paste0(ua, "/", options()[["UA.dataRetrieval"]]) } From 46dfe13ca77071a186358581181447215f3d8bbb Mon Sep 17 00:00:00 2001 From: Laura A DeCicco Date: Thu, 31 Oct 2024 15:37:15 -0500 Subject: [PATCH 2/9] Change custom UA to Sys.get. --- .github/workflows/R-CMD-check.yaml | 1 + .gitlab-ci.yml | 1 + R/getWebServiceData.R | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index d3b52d60..50053a33 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -29,6 +29,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes + CUSTOM_DR_UA: GitHub_CI steps: - uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc04d6d8..4df3b424 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,6 +30,7 @@ variables: BUILD_LOGS_DIR: "$CI_PROJECT_DIR/ci/logs" NOT_CRAN: "true" PAGES_OUTDIR: "$CI_PROJECT_DIR/public" + CUSTOM_DR_UA: "GitLab_CI" build-image: stage: build diff --git a/R/getWebServiceData.R b/R/getWebServiceData.R index 68c2e78e..b58c5b26 100644 --- a/R/getWebServiceData.R +++ b/R/getWebServiceData.R @@ -137,8 +137,8 @@ default_ua <- function() { ua <- paste0(names(versions), "/", versions, collapse = " ") - if ("UA.dataRetrieval" %in% names(options())) { - ua <- paste0(ua, "/", options()[["UA.dataRetrieval"]]) + if (Sys.getenv("GitHub_CI") != "") { + ua <- paste0(ua, "/", Sys.getenv("GitHub_CI")) } return(ua) From 04ae77148eaef533dd3b241b3623b3807528d223 Mon Sep 17 00:00:00 2001 From: Laura A DeCicco Date: Thu, 31 Oct 2024 15:37:45 -0500 Subject: [PATCH 3/9] forgot a GHA --- .github/workflows/test-coverage.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 4dc1b402..f72471c4 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -11,6 +11,8 @@ name: test-coverage jobs: test-coverage: runs-on: macOS-latest + env: + CUSTOM_DR_UA = GitHub_CI steps: - uses: actions/checkout@c0a81a463886bb75afe234e07a9fd5bb79219196 From d859170a299081f018b8e04640a65e6e039c8b75 Mon Sep 17 00:00:00 2001 From: Laura A DeCicco Date: Thu, 31 Oct 2024 15:42:28 -0500 Subject: [PATCH 4/9] is this better for yaml? --- .github/workflows/R-CMD-check.yaml | 2 +- .github/workflows/pkgdown.yaml | 1 + .github/workflows/test-coverage.yaml | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 50053a33..e164d0a6 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -29,7 +29,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes - CUSTOM_DR_UA: GitHub_CI + CUSTOM_DR_UA: 'GitHub_CI' steps: - uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 71eb71ac..97de052a 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -24,6 +24,7 @@ jobs: pkgdown: runs-on: ubuntu-latest # Only restrict concurrency for non-PR jobs + env: CUSTOM_DR_UA: 'GitHub_CI' concurrency: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index f72471c4..4bba326c 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -11,8 +11,9 @@ name: test-coverage jobs: test-coverage: runs-on: macOS-latest - env: - CUSTOM_DR_UA = GitHub_CI + + env: CUSTOM_DR_UA: 'GitHub_CI' + steps: - uses: actions/checkout@c0a81a463886bb75afe234e07a9fd5bb79219196 From f78d99f450d3797643dd83290b1ac50064653548 Mon Sep 17 00:00:00 2001 From: Laura A DeCicco Date: Fri, 1 Nov 2024 09:15:59 -0500 Subject: [PATCH 5/9] spelling --- .github/workflows/test-coverage.yaml | 5 ++++- R/getWebServiceData.R | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 4bba326c..ce05609b 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -12,7 +12,10 @@ jobs: test-coverage: runs-on: macOS-latest - env: CUSTOM_DR_UA: 'GitHub_CI' + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + CUSTOM_DR_UA: 'GitHub_CI' steps: - uses: actions/checkout@c0a81a463886bb75afe234e07a9fd5bb79219196 diff --git a/R/getWebServiceData.R b/R/getWebServiceData.R index b58c5b26..829cabad 100644 --- a/R/getWebServiceData.R +++ b/R/getWebServiceData.R @@ -137,8 +137,8 @@ default_ua <- function() { ua <- paste0(names(versions), "/", versions, collapse = " ") - if (Sys.getenv("GitHub_CI") != "") { - ua <- paste0(ua, "/", Sys.getenv("GitHub_CI")) + if (Sys.getenv("CUSTOM_DR_UA") != "") { + ua <- paste0(ua, "/", Sys.getenv("CUSTOM_DR_UA")) } return(ua) From ff9264ee50ae5284f8dee8d8df2450c76a5cb9e7 Mon Sep 17 00:00:00 2001 From: Laura A DeCicco Date: Fri, 1 Nov 2024 09:17:54 -0500 Subject: [PATCH 6/9] yml? --- .github/workflows/pkgdown.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 97de052a..32cdbac6 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -24,7 +24,8 @@ jobs: pkgdown: runs-on: ubuntu-latest # Only restrict concurrency for non-PR jobs - env: CUSTOM_DR_UA: 'GitHub_CI' + env: + CUSTOM_DR_UA: 'GitHub_CI' concurrency: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: From 1227ba219e1b1a567a1ded6fe6da2daae1c31112 Mon Sep 17 00:00:00 2001 From: Laura A DeCicco Date: Fri, 1 Nov 2024 09:26:40 -0500 Subject: [PATCH 7/9] does this help --- .github/workflows/pkgdown.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 32cdbac6..97feaa49 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -26,6 +26,7 @@ jobs: # Only restrict concurrency for non-PR jobs env: CUSTOM_DR_UA: 'GitHub_CI' + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} concurrency: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: From a4a3e0a2e8808bcf2d8d3113ebe459d21da48e3c Mon Sep 17 00:00:00 2001 From: Laura A DeCicco Date: Fri, 1 Nov 2024 09:33:17 -0500 Subject: [PATCH 8/9] yml --- .github/workflows/pkgdown.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 97feaa49..80a8833b 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -24,13 +24,11 @@ jobs: pkgdown: runs-on: ubuntu-latest # Only restrict concurrency for non-PR jobs - env: - CUSTOM_DR_UA: 'GitHub_CI' - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} concurrency: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + CUSTOM_DR_UA: 'GitHub_CI' steps: - uses: actions/checkout@c0a81a463886bb75afe234e07a9fd5bb79219196 From 2374fd650a1037ed8bb84d313b35d16e2afef2a8 Mon Sep 17 00:00:00 2001 From: Laura A DeCicco Date: Tue, 5 Nov 2024 09:13:47 -0600 Subject: [PATCH 9/9] Add some documentation --- DESCRIPTION | 2 +- NEWS | 4 ++++ R/getWebServiceData.R | 3 ++- man/getWebServiceData.Rd | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e879a86b..24dcf8fa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dataRetrieval Type: Package Title: Retrieval Functions for USGS and EPA Hydrology and Water Quality Data -Version: 2.7.17 +Version: 2.7.17.9000 Authors@R: c( person("Laura", "DeCicco", role = c("aut","cre"), email = "ldecicco@usgs.gov", diff --git a/NEWS b/NEWS index 2706f45b..f58e1c0e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +dataRetrieval 2.7.18 +=================== +* Added a way to include a custom user-agent suffix via an enviornmental variable "CUSTOM_DR_UA" + dataRetrieval 2.7.17 =================== * Fixed bug with server problems causing errors. diff --git a/R/getWebServiceData.R b/R/getWebServiceData.R index 829cabad..6c26066f 100644 --- a/R/getWebServiceData.R +++ b/R/getWebServiceData.R @@ -1,7 +1,8 @@ #' Function to return data from web services #' #' This function accepts a url parameter, and returns the raw data. The function enhances -#' \code{\link[httr]{GET}} with more informative error messages. +#' \code{\link[httr]{GET}} with more informative error messages. To add a +#' custom user agent, create an environmental variable: CUSTOM_DR_UA #' #' @param obs_url character containing the url for the retrieval #' @param \dots information to pass to header request diff --git a/man/getWebServiceData.Rd b/man/getWebServiceData.Rd index 5e2d0571..aae0af58 100644 --- a/man/getWebServiceData.Rd +++ b/man/getWebServiceData.Rd @@ -16,7 +16,8 @@ raw data from web services } \description{ This function accepts a url parameter, and returns the raw data. The function enhances -\code{\link[httr]{GET}} with more informative error messages. +\code{\link[httr]{GET}} with more informative error messages. To add a +custom user agent, create an environmental variable: CUSTOM_DR_UA } \examples{ \dontshow{if (is_dataRetrieval_user()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}