diff --git a/NAMESPACE b/NAMESPACE index 62cbf8f..d03e0c2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +S3method(call_cognitive_endpoint,cognitive_endpoint) S3method(print,cognitive_endpoint) export(az_cognitive_service) export(call_cognitive_endpoint) diff --git a/R/endpoint.R b/R/endpoint.R index a8acd07..4d77bbd 100644 --- a/R/endpoint.R +++ b/R/endpoint.R @@ -73,6 +73,7 @@ print.cognitive_endpoint <- function(x, ...) #' @param http_verb The HTTP verb for the REST call. #' @param http_status_handler How to handle a failed REST call. `stop`, `warn` and `message` will call the corresponding `*_for_status` handler in the httr package; `pass` will return the raw response object unchanged. The last one is mostly intended for debugging purposes. #' @param auth_header The name of the HTTP request header for authentication. Only used if a subscription key is supplied. +#' @param ... Further arguments passed to lower-level functions. #' @details #' This function does the low-level work of constructing a HTTP request and then calling the REST endpoint. It is meant to be used by other packages that provide higher-level views of the service functionality. #' @@ -105,10 +106,18 @@ print.cognitive_endpoint <- function(x, ...) #' #' } #' @export -call_cognitive_endpoint <- function(endpoint, operation, options=list(), headers=list(), body=NULL, encode=NULL, - http_verb=c("GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"), - http_status_handler=c("stop", "warn", "message", "pass"), - auth_header="ocp-apim-subscription-key") +call_cognitive_endpoint <- function(endpoint, ...) +{ + UseMethod("call_cognitive_endpoint") +} + +#' @rdname call_cognitive_endpoint +#' @export +call_cognitive_endpoint.cognitive_endpoint <- function(endpoint, operation, + options=list(), headers=list(), body=NULL, encode=NULL, ..., + http_verb=c("GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"), + http_status_handler=c("stop", "warn", "message", "pass"), + auth_header="ocp-apim-subscription-key") { url <- endpoint$url url$path <- file.path(url$path, operation) diff --git a/man/call_cognitive_endpoint.Rd b/man/call_cognitive_endpoint.Rd index 2ba1bea..20b2f7f 100644 --- a/man/call_cognitive_endpoint.Rd +++ b/man/call_cognitive_endpoint.Rd @@ -2,17 +2,22 @@ % Please edit documentation in R/endpoint.R \name{call_cognitive_endpoint} \alias{call_cognitive_endpoint} +\alias{call_cognitive_endpoint.cognitive_endpoint} \title{Call a Cognitive Service REST endpoint} \usage{ -call_cognitive_endpoint(endpoint, operation, options = list(), - headers = list(), body = NULL, encode = NULL, - http_verb = c("GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"), +call_cognitive_endpoint(endpoint, ...) + +\method{call_cognitive_endpoint}{cognitive_endpoint}(endpoint, operation, + options = list(), headers = list(), body = NULL, encode = NULL, + ..., http_verb = c("GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"), http_status_handler = c("stop", "warn", "message", "pass"), auth_header = "ocp-apim-subscription-key") } \arguments{ \item{endpoint}{An object of class \code{cognitive_endpoint}.} +\item{...}{Further arguments passed to lower-level functions.} + \item{operation}{The operation to perform.} \item{options}{Any query parameters that the operation takes.}