From 64edb051bbee87a8eb5e475dee304ab07b3aba71 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 15 Jun 2017 07:12:44 +0100 Subject: [PATCH 1/2] Document cost functions in package documentation --- R/AzureSMR-package.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/R/AzureSMR-package.R b/R/AzureSMR-package.R index de98540..806e3ce 100644 --- a/R/AzureSMR-package.R +++ b/R/AzureSMR-package.R @@ -15,6 +15,10 @@ #' - [azureCreateStorageAccount()] #' - [azureListStorageContainers()] #' - [azureListStorageBlobs()] +#' - [azureGetBlob()] +#' - [azurePutBlob()] +#' - [azureDeleteBlob()] +#' - [azureBlobFind()] #' * Virtual Machines #' - List VMs: [azureListVM()] #' - To create a virtual machine, use [azureDeployTemplate()] with a suitable template @@ -33,7 +37,10 @@ #' - [azureCreateBatchAccount()] #' - [azureDeleteBatchAccount()] #' - [azureBatchGetKey()] -#' +#' * Cost functions: +#' - [azureDataConsumption()] +#' - [azurePricingRates()] +#' - [azureExpenseCalculator()] #' #' @name AzureSMR #' @aliases AzureSMR-package From d18418db6cb630de89b8bec6db79b4769691823a Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 15 Jun 2017 07:13:29 +0100 Subject: [PATCH 2/2] Fix documentation issues; add @family to roxygen --- NAMESPACE | 6 ++++ R/AzureCost.R | 59 +++++++++++------------------------ man/AzureSMR.Rd | 10 ++++++ man/azureDataConsumption.Rd | 37 +++++++--------------- man/azureExpenseCalculator.Rd | 18 ++++------- man/azurePricingRates.Rd | 10 +++--- 6 files changed, 58 insertions(+), 82 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index b6c9142..608a1c5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,6 +17,7 @@ export(azureCreateHDI) export(azureCreateResourceGroup) export(azureCreateStorageAccount) export(azureCreateStorageContainer) +export(azureDataConsumption) export(azureDeleteBatchAccount) export(azureDeleteBlob) export(azureDeleteDeploy) @@ -27,6 +28,7 @@ export(azureDeleteVM) export(azureDeletestorageAccount) export(azureDeployStatus) export(azureDeployTemplate) +export(azureExpenseCalculator) export(azureGetAllVMstatus) export(azureGetBlob) export(azureHDIConf) @@ -44,6 +46,7 @@ export(azureListStorageBlobs) export(azureListStorageContainers) export(azureListSubscriptions) export(azureListVM) +export(azurePricingRates) export(azurePutBlob) export(azureResizeHDI) export(azureRunScriptAction) @@ -86,6 +89,9 @@ importFrom(httr,headers) importFrom(httr,http_status) importFrom(httr,status_code) importFrom(jsonlite,fromJSON) +importFrom(lubridate,hour) +importFrom(lubridate,minute) +importFrom(lubridate,second) importFrom(miniUI,gadgetTitleBar) importFrom(miniUI,miniContentPanel) importFrom(miniUI,miniPage) diff --git a/R/AzureCost.R b/R/AzureCost.R index c5e7582..33e4d0e 100644 --- a/R/AzureCost.R +++ b/R/AzureCost.R @@ -1,25 +1,12 @@ -#' Get data consumption of an Azure subscription for a time period. Aggregation -#' method can be either daily based or hourly based. +#' Get data consumption of an Azure subscription for a time period. + +#' Aggregation method can be either daily based or hourly based. #' -#' @note Formats of start time point and end time point follow ISO 8601 standard -#' Say if one would like to calculate data consumption between Feb 21, 2017 to -#' Feb 25, 2017, with an aggregation granularity of "daily based", the inputs -#' should be "2017-02-21 00:00:00" and "2017-02-25 00:00:00", for start time -#' point and end time point, respectively. If the aggregation granularity is -#' hourly based, the inputs can be "2017-02-21 01:00:00" and -#' "2017-02-21 02:00:00", for start and end time point, respectively. -#' NOTE by default the Azure data -#' consumption API does not allow an aggregation granularity that is finer -#' than an hour. In the case of "hourly based" granularity, if the time -#' difference between start and end time point is less than an hour, data -#' consumption will still be calculated hourly based with end time postponed. -#' For example, if the start time point and end time point are "2017-02-21 -#' 00:00:00" and "2017-02-21 00:45:00", the actual returned results are -#' data consumption in the interval of "2017-02-21 00:00:00" and -#' "2017-02-21 01:00:00". However this calculation is merely for retrieving -#' the information of an existing instance instance (e.g., meterId) with -#' which the pricing rate is multiplied by to obtain the overall expense. -#' Time zone of all time inputs are synchronized to UTC. +#' Formats of start time point and end time point follow ISO 8601 standard. For example, if you want to calculate data consumption between Feb 21, 2017 to Feb 25, 2017, with an aggregation granularity of "daily based", the inputs should be "2017-02-21 00:00:00" and "2017-02-25 00:00:00", for start time point and end time point, respectively. +#' If the aggregation granularity is hourly based, the inputs can be "2017-02-21 01:00:00" and "2017-02-21 02:00:00", for start and end time point, respectively. +#' NOTE by default the Azure data consumption API does not allow an aggregation granularity that is finer than an hour. In the case of "hourly based" granularity, if the time difference between start and end time point is less than an hour, data consumption will still be calculated hourly based with end time postponed. +#' For example, if the start time point and end time point are "2017-02-21 00:00:00" and "2017-02-21 00:45:00", the actual returned results are data consumption in the interval of "2017-02-21 00:00:00" and "2017-02-21 01:00:00". However this calculation is merely for retrieving the information of an existing instance instance (e.g. `meterId`) with which the pricing rate is multiplied by to obtain the overall expense. +#' Time zone of all time inputs are synchronized to UTC. #' #' @inheritParams setAzureContext #' @@ -28,11 +15,10 @@ #' all instances under subscription. #' #' @param timeStart Start time. -#' #' @param timeEnd End time. -#' -#' @param granularity Aggregation granularity. Can be either "Daily" or -#' "Hourly". +#' @param granularity Aggregation granularity. Can be either "Daily" or "Hourly". +#' +#' @family Cost functions #' @export azureDataConsumption <- function(azureActiveContext, instance="", @@ -239,22 +225,20 @@ azureDataConsumption <- function(azureActiveContext, return(df_use) } + #' Get pricing details of resources under a subscription. #' #' @inheritParams setAzureContext #' #' @param currency Currency in which price rating is measured. -#' #' @param locale Locality information of subscription. -#' -#' @param offerId Offer ID of the subscription. Detailed information can be -#' found at https://azure.microsoft.com/en-us/support/legal/offer-details/ +#' @param offerId Offer ID of the subscription. For more information see https://azure.microsoft.com/en-us/support/legal/offer-details/ #' #' @param region region information about the subscription. #' -#' @note The pricing rates function wraps API calls to Azure RateCard and -#' current only the API supports only for Pay-As-You-Go offer scheme. +#' @note The pricing rates function wraps API calls to Azure RateCard and currently the API supports only the Pay-As-You-Go offer scheme. #' +#' @family Cost functions #' @export azurePricingRates <- function(azureActiveContext, currency, @@ -320,24 +304,19 @@ azurePricingRates <- function(azureActiveContext, df_meter } + #' Calculate cost of using a specific instance of Azure for certain period. #' +#'Note if difference between \code{timeStart} and \code{timeEnd} is less than the finest granularity, e.g., "Hourly" (we notice this is a usual case when one needs to be aware of the charges of a job that takes less than an hour), the expense will be estimated based solely on computation hour. That is, the total expense is the multiplication of computation hour and pricing rate of the requested instance. +#' #' @inheritParams setAzureContext -#' #' @inheritParams azureDataConsumption -#' #' @inheritParams azurePricingRates #' #' @return Total cost measured in the given currency of the specified Azure #' instance in the period. #' -#' @note Note if difference between \code{timeStart} and \code{timeEnd} is -#' less than the finest granularity, e.g., "Hourly" (we notice this is a -#' usual case when one needs to be aware of the charges of a job that takes -#' less than an hour), the expense will be estimated based solely on computation -#' hour. That is, the total expense is the multiplication of computation hour -#' and pricing rate of the requested instance. -#' +#' @family Cost functions #' @export azureExpenseCalculator <- function(azureActiveContext, instance="", diff --git a/man/AzureSMR.Rd b/man/AzureSMR.Rd index 2c8a0bc..80f981c 100644 --- a/man/AzureSMR.Rd +++ b/man/AzureSMR.Rd @@ -28,6 +28,10 @@ This enables you to use and change many Azure resources. The following is an inc \item \code{\link[=azureCreateStorageAccount]{azureCreateStorageAccount()}} \item \code{\link[=azureListStorageContainers]{azureListStorageContainers()}} \item \code{\link[=azureListStorageBlobs]{azureListStorageBlobs()}} +\item \code{\link[=azureGetBlob]{azureGetBlob()}} +\item \code{\link[=azurePutBlob]{azurePutBlob()}} +\item \code{\link[=azureDeleteBlob]{azureDeleteBlob()}} +\item \code{\link[=azureBlobFind]{azureBlobFind()}} } \item Virtual Machines \itemize{ @@ -53,6 +57,12 @@ This enables you to use and change many Azure resources. The following is an inc \item \code{\link[=azureDeleteBatchAccount]{azureDeleteBatchAccount()}} \item \code{\link[=azureBatchGetKey]{azureBatchGetKey()}} } +\item Cost functions: +\itemize{ +\item \code{\link[=azureDataConsumption]{azureDataConsumption()}} +\item \code{\link[=azurePricingRates]{azurePricingRates()}} +\item \code{\link[=azureExpenseCalculator]{azureExpenseCalculator()}} +} } } \keyword{package} diff --git a/man/azureDataConsumption.Rd b/man/azureDataConsumption.Rd index c2ee776..9a5afb2 100644 --- a/man/azureDataConsumption.Rd +++ b/man/azureDataConsumption.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/AzureCost.R \name{azureDataConsumption} \alias{azureDataConsumption} -\title{Get data consumption of an Azure subscription for a time period. Aggregation -method can be either daily based or hourly based.} +\title{Get data consumption of an Azure subscription for a time period. +Aggregation method can be either daily based or hourly based.} \usage{ azureDataConsumption(azureActiveContext, instance = "", timeStart, timeEnd, granularity = "Hourly", verbose = FALSE) @@ -19,31 +19,16 @@ all instances under subscription.} \item{timeEnd}{End time.} -\item{granularity}{Aggregation granularity. Can be either "Daily" or -"Hourly".} +\item{granularity}{Aggregation granularity. Can be either "Daily" or "Hourly".} } \description{ -Get data consumption of an Azure subscription for a time period. Aggregation -method can be either daily based or hourly based. -} -\note{ -Formats of start time point and end time point follow ISO 8601 standard -Say if one would like to calculate data consumption between Feb 21, 2017 to -Feb 25, 2017, with an aggregation granularity of "daily based", the inputs -should be "2017-02-21 00:00:00" and "2017-02-25 00:00:00", for start time -point and end time point, respectively. If the aggregation granularity is -hourly based, the inputs can be "2017-02-21 01:00:00" and -"2017-02-21 02:00:00", for start and end time point, respectively. -NOTE by default the Azure data -consumption API does not allow an aggregation granularity that is finer -than an hour. In the case of "hourly based" granularity, if the time -difference between start and end time point is less than an hour, data -consumption will still be calculated hourly based with end time postponed. -For example, if the start time point and end time point are "2017-02-21 -00:00:00" and "2017-02-21 00:45:00", the actual returned results are -data consumption in the interval of "2017-02-21 00:00:00" and -"2017-02-21 01:00:00". However this calculation is merely for retrieving -the information of an existing instance instance (e.g., meterId) with -which the pricing rate is multiplied by to obtain the overall expense. +Formats of start time point and end time point follow ISO 8601 standard. For example, if you want to calculate data consumption between Feb 21, 2017 to Feb 25, 2017, with an aggregation granularity of "daily based", the inputs should be "2017-02-21 00:00:00" and "2017-02-25 00:00:00", for start time point and end time point, respectively. +If the aggregation granularity is hourly based, the inputs can be "2017-02-21 01:00:00" and "2017-02-21 02:00:00", for start and end time point, respectively. +NOTE by default the Azure data consumption API does not allow an aggregation granularity that is finer than an hour. In the case of "hourly based" granularity, if the time difference between start and end time point is less than an hour, data consumption will still be calculated hourly based with end time postponed. +For example, if the start time point and end time point are "2017-02-21 00:00:00" and "2017-02-21 00:45:00", the actual returned results are data consumption in the interval of "2017-02-21 00:00:00" and "2017-02-21 01:00:00". However this calculation is merely for retrieving the information of an existing instance instance (e.g. \code{meterId}) with which the pricing rate is multiplied by to obtain the overall expense. Time zone of all time inputs are synchronized to UTC. } +\seealso{ +Other Cost functions: \code{\link{azureExpenseCalculator}}, + \code{\link{azurePricingRates}} +} diff --git a/man/azureExpenseCalculator.Rd b/man/azureExpenseCalculator.Rd index 4bd479f..432e1e4 100644 --- a/man/azureExpenseCalculator.Rd +++ b/man/azureExpenseCalculator.Rd @@ -18,15 +18,13 @@ all instances under subscription.} \item{timeEnd}{End time.} -\item{granularity}{Aggregation granularity. Can be either "Daily" or -"Hourly".} +\item{granularity}{Aggregation granularity. Can be either "Daily" or "Hourly".} \item{currency}{Currency in which price rating is measured.} \item{locale}{Locality information of subscription.} -\item{offerId}{Offer ID of the subscription. Detailed information can be -found at https://azure.microsoft.com/en-us/support/legal/offer-details/} +\item{offerId}{Offer ID of the subscription. For more information see https://azure.microsoft.com/en-us/support/legal/offer-details/} \item{region}{region information about the subscription.} } @@ -35,13 +33,9 @@ Total cost measured in the given currency of the specified Azure instance in the period. } \description{ -Calculate cost of using a specific instance of Azure for certain period. +Note if difference between \code{timeStart} and \code{timeEnd} is less than the finest granularity, e.g., "Hourly" (we notice this is a usual case when one needs to be aware of the charges of a job that takes less than an hour), the expense will be estimated based solely on computation hour. That is, the total expense is the multiplication of computation hour and pricing rate of the requested instance. } -\note{ -Note if difference between \code{timeStart} and \code{timeEnd} is -less than the finest granularity, e.g., "Hourly" (we notice this is a -usual case when one needs to be aware of the charges of a job that takes -less than an hour), the expense will be estimated based solely on computation -hour. That is, the total expense is the multiplication of computation hour -and pricing rate of the requested instance. +\seealso{ +Other Cost functions: \code{\link{azureDataConsumption}}, + \code{\link{azurePricingRates}} } diff --git a/man/azurePricingRates.Rd b/man/azurePricingRates.Rd index c3e678d..383fcab 100644 --- a/man/azurePricingRates.Rd +++ b/man/azurePricingRates.Rd @@ -14,8 +14,7 @@ azurePricingRates(azureActiveContext, currency, locale, offerId, region, \item{locale}{Locality information of subscription.} -\item{offerId}{Offer ID of the subscription. Detailed information can be -found at https://azure.microsoft.com/en-us/support/legal/offer-details/} +\item{offerId}{Offer ID of the subscription. For more information see https://azure.microsoft.com/en-us/support/legal/offer-details/} \item{region}{region information about the subscription.} } @@ -23,6 +22,9 @@ found at https://azure.microsoft.com/en-us/support/legal/offer-details/} Get pricing details of resources under a subscription. } \note{ -The pricing rates function wraps API calls to Azure RateCard and -current only the API supports only for Pay-As-You-Go offer scheme. +The pricing rates function wraps API calls to Azure RateCard and currently the API supports only the Pay-As-You-Go offer scheme. +} +\seealso{ +Other Cost functions: \code{\link{azureDataConsumption}}, + \code{\link{azureExpenseCalculator}} }