DecafClient | R Documentation |
Instances of this class can be used for conveniently issuing HTTP requests to various APIs of remote DECAF Instances.
A DECAF Instance exposes its capabilities and data it hosts over APIs which can be then consumed by itself (to enhance its feature-set) or third-party systems.
The API landscape of DECAF is large and constantly evolving. There are multiple APIs for a given DECAF Instance:
DECAF Barista
DECAF Estate
DECAF Microlot
DECAF Functions
DECAF Beanbag
This class exposes a property called bare
that provides the underlying HTTP
client that can be used for all sorts of DECAF API calls. It is indeed an
instance of crul::HttpClient
class of
crul library (not
curl
). crul
library is built using R6 classes. It is very powerful and
provides all low-level functionality we needed to implement individual DECAF
API Client(s).
We are going to improve the functionality this class provides by providing higher-level clients for individual DECAF APIs.
url
Base URL of the remote DECAF Instance.
bare
Bare HTTP client for the remote DECAF Instance.
This is a crul::HttpClient
instance that is ready to issue requests
to remote DECAF Instance. Indeed, this instance is sufficient for any
kind of API communication with remote DECAF Instance.
The API namespace is not provided. Therefore, the call-site needs to
pass the absolute URL path (such as /api/version/
) when using this
bare HTTP client.
new()
Creates a DECAF client.
DecafClient$new(url, credentials)
url
Base URL of the remote DECAF instance.
credentials
Authentication credentials for the remote DECAF instance.
This should be a named-list of credentials. Key-value pairs of this list depends on the authentication method. Keys should be one of:
username
and password
for "Basic Authentication" method.
apikey
and apisecret
for "API Key Authentication" method.
token
for "API Token Authentication" method.
header
for passing Authorization
HTTP header as is.
A new DecafClient
object.
client <- rdecaf::DecafClient$new( url = "https://httpbin.org", credentials = list(username = "hebele", password = "hubele") ) client <- rdecaf::DecafClient$new( url = "https://httpbin.org", credentials = list(apikey = "hebele", apisecret = "hubele") ) client <- rdecaf::DecafClient$new( url = "https://httpbin.org", credentials = list(token = "zamazingo") ) client <- rdecaf::DecafClient$new( url = "https://httpbin.org", credentials = list(header = "Token zamazingo") )
info()
Prints rudimentary information about the DECAF Instance.
DecafClient$info()
print()
Provides the print function for DecafClient
object.
DecafClient$print()
clone()
The objects of this class are cloneable with this method.
DecafClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------ ## Method `DecafClient$new` ## ------------------------------------------------ client <- rdecaf::DecafClient$new( url = "https://httpbin.org", credentials = list(username = "hebele", password = "hubele") ) client <- rdecaf::DecafClient$new( url = "https://httpbin.org", credentials = list(apikey = "hebele", apisecret = "hubele") ) client <- rdecaf::DecafClient$new( url = "https://httpbin.org", credentials = list(token = "zamazingo") ) client <- rdecaf::DecafClient$new( url = "https://httpbin.org", credentials = list(header = "Token zamazingo") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.