DecafClient: DECAF API Client

DecafClientR Documentation

DECAF API Client

Description

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:

  1. DECAF Barista

  2. DECAF Estate

  3. DECAF Microlot

  4. DECAF Functions

  5. 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.

Public fields

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.

Methods

Public methods


Method new()

Creates a DECAF client.

Usage
DecafClient$new(url, credentials)
Arguments
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:

  1. username and password for "Basic Authentication" method.

  2. apikey and apisecret for "API Key Authentication" method.

  3. token for "API Token Authentication" method.

  4. header for passing Authorization HTTP header as is.

Returns

A new DecafClient object.

Examples
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")
)

Method info()

Prints rudimentary information about the DECAF Instance.

Usage
DecafClient$info()

Method print()

Provides the print function for DecafClient object.

Usage
DecafClient$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
DecafClient$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## 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")
)

telostat/rdecaf documentation built on June 22, 2022, 8:35 p.m.