Response-class: 'Item', 'Collection' and 'Response' objects

Description Item Accessors Collection Accessors Subsetting Methods Author(s) Examples

Description

These virtual classes provide the building blocks for the containers return by quering various BaseSpace resource. They are modeled after the Response container defined by the REST API.

Conceptually there are two response types exposed by BaseSpace, an individual response and a collection response. The former, modeled by the Item S4 class, is used when querying an individual item/instance within a resource. The later is used for listing the items/instances available for a given resource and is modeled by the Collection S4 class.

Item Accessors

The Item class models a simple unordered set of key/value pairs. There is a core set of keys, for which access methods are defined and which are inherited by any child class.

In the following x is an Item object.

$:

The $ operator can be used to access the Item elements. When x is an Item object this is equivalet to @. But one can think at it as user level operator. Unlike @ the replace method is not implemented for $.

Id(x):

Id of the resource. Character string, though it will always be an integer.

Name(x):

Name of the selected resource.

Href(x):

Location of the resource in the API. The first component of the URI is the version of the REST API.

DateCreated(x):

When this resource was created. Character string. It can be converted to a Date instace by as.Date(DateCreated(x)).

UserOwnedBy(x):

Information about the User who owns this resource. At this moment this is a list object, but it might be replace with an object at a future point.

Status(x):

The status of the resource. Can be of any type and it will be defined by the classes extended Item.

HrefBaseSpaceUI(x):

The location of this project in BaseSpace. Character string giving the complete URL within the BaseSpace dashboard.

Collection Accessors

The Collection class models an ordered set of Item objects and a set of predefined attributes. The interface provided by the Item class is implemented by this class. However, since we deal with an ordered set of objects, the methods and the access methods, return a vector of the same length as the size of the collection.

In the following x is a Collection object.

All accesor implemented by the item class are implemented by Collection class. However here the return value is a vector. If x has 2 elements, then Id(x) will be a vector with 2 elements. The same stands for the general accessor $.

length(x):

Returns the number of elements in Collection x.

Items(x):

List of Item objects.

TotalCount(x):

The total number of items in the collection as reported by the queried resource.

Offset(x):

The starting point the collection was read from.

Limit(x):

The maximum number of items returned. Ranges from 0 to 1024.

SortDir(x):

The way the collection is sorted, either ascending or descending.

SortBy(x):

The field to use to sort the collection.

Subsetting

Comming soon ...

Methods

length(x):

Returns the number of elements in Collection x.

show(x):

Prints the object.

as.list(x):

R list representation of the object.

Author(s)

Adrian Alexa

Examples

1
2
3
showClass("Item")
showClass("Collection")
showClass("Response")

BaseSpaceR documentation built on Nov. 8, 2020, 5:12 p.m.