From 62d9f0973afe280896e01a8a61a7c5ce27632c45 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 16 Jan 2024 16:49:31 +0000 Subject: [PATCH] R code to add definitions data back to the bucket --- NAMESPACE | 1 + R/add_definitions_to_bucket.R | 14 ++++++++++++++ man/add_definitions_to_bucket.Rd | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 R/add_definitions_to_bucket.R create mode 100644 man/add_definitions_to_bucket.Rd diff --git a/NAMESPACE b/NAMESPACE index dafdb0f..73049b3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ # Generated by roxygen2: do not edit by hand export("%>%") +export(add_definitions_to_bucket) export(annual_rainfall_summaries) export(annual_temperature_summaries) export(crop_success_probabilities) diff --git a/R/add_definitions_to_bucket.R b/R/add_definitions_to_bucket.R new file mode 100644 index 0000000..05c4c13 --- /dev/null +++ b/R/add_definitions_to_bucket.R @@ -0,0 +1,14 @@ +#' Add New Definitions to Google Cloud Storage Bucket +#' +#' This function adds a new definitions file with a timestamp to a specified Google Cloud Storage (GCS) bucket. The new definitions are sourced from a JSON file provided as input. +#' +#' @param country A character vector specifying the country or countries from which to get the definitions data. Options are `"mz"` and `"zm"`. +#' @param station_id A character string specifying the ID of the station for which to get the definitions data. +#' @param new_definitions A character vector specifying the path to the JSON file containing the new definitions. +#' +#' @export +#' @details +#' The function creates a timestamp in the format "YYYYMMDDHHMMSS" and appends it to the station_id to form the filename. It then reads the provided JSON file, creates a new JSON file with the timestamped filename, and uploads it to the specified GCS bucket. +add_definitions_to_bucket <- function(country, station_id, new_definitions){ + return(epicsadata::add_definitions_to_bucket(country = country, station_id = station_id, new_definitions = new_definitions)) +} diff --git a/man/add_definitions_to_bucket.Rd b/man/add_definitions_to_bucket.Rd new file mode 100644 index 0000000..4883545 --- /dev/null +++ b/man/add_definitions_to_bucket.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add_definitions_to_bucket.R +\name{add_definitions_to_bucket} +\alias{add_definitions_to_bucket} +\title{Add New Definitions to Google Cloud Storage Bucket} +\usage{ +add_definitions_to_bucket(country, station_id, new_definitions) +} +\arguments{ +\item{country}{A character vector specifying the country or countries from which to get the definitions data. Options are \code{"mz"} and \code{"zm"}.} + +\item{station_id}{A character string specifying the ID of the station for which to get the definitions data.} + +\item{new_definitions}{A character vector specifying the path to the JSON file containing the new definitions.} +} +\description{ +This function adds a new definitions file with a timestamp to a specified Google Cloud Storage (GCS) bucket. The new definitions are sourced from a JSON file provided as input. +} +\details{ +The function creates a timestamp in the format "YYYYMMDDHHMMSS" and appends it to the station_id to form the filename. It then reads the provided JSON file, creates a new JSON file with the timestamped filename, and uploads it to the specified GCS bucket. +}