Skip to content

Commit

Permalink
Merge pull request #737 from ldecicco-USGS/main
Browse files Browse the repository at this point in the history
Change custom UA to environmental variable
  • Loading branch information
ldecicco-USGS authored Nov 5, 2024
2 parents 51f8ffb + 2374fd6 commit 8277747
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
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

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ name: test-coverage
jobs:
test-coverage:
runs-on: macOS-latest

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
CUSTOM_DR_UA: 'GitHub_CI'

steps:
- uses: actions/checkout@c0a81a463886bb75afe234e07a9fd5bb79219196

Expand Down
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 4 additions & 3 deletions R/getWebServiceData.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -137,8 +138,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("CUSTOM_DR_UA") != "") {
ua <- paste0(ua, "/", Sys.getenv("CUSTOM_DR_UA"))
}

return(ua)
Expand Down
3 changes: 2 additions & 1 deletion man/getWebServiceData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8277747

Please sign in to comment.