Skip to main content

Demo.REST.DirectoryService

class Demo.REST.DirectoryService extends EnsLib.REST.Service

This is a sample REST service implementing a directory of Person and Employee records. Not every Person is an Employee. The CRUD (Create,Retrieve,Update,Delete) interface is implemented via the REST/HTTP commands PUT,GET,POST,and DELETE respectively. Records of interest may be retrieved via type and key fields "name" and "ssn". Wildcards containing * and ? are supported. The resulting HTTP body of a successful GET query may be a partially or fully populated JSON object, depending on the field requested, or a JSON array of such JSON objects if a wildcard was used. Example REST URLs: GET /directory/employee/name/Q*/salary GET /directory/employee/name/Quentin, Fred A. GET /directory/employee/ssn/123-45-6789/*

Method Inventory

Parameters

parameter ADAPTER = EnsLib.HTTP.InboundAdapter;
Inherited description: Name of the adapter class - override this to "" if you want to use only the regular HTTP mechanism and not the custom-port HTTP InboundAdapter.
parameter EnsServicePrefix = |directory;
Inherited description: This prefix will be removed from the beginning of the actual URL before matching it against the UrlMap. If this prefix begins with '^' then the CSP Application will also be removed from the beginning of the URL if this service is being invoked via the CSP gateway. If this prefix begins with '|' then the Ensemble Config Name for this service will be removed from the beginning of the URL, as well as the CSP Application if this service is being invoked via the CSP gateway.

Methods

classmethod OnErrorStream(pStatus As %Library.Status, pInstance As EnsLib.HTTP.Service)
Control the type and content of error returned to the REST caller
method createPerson(pInput As %Library.AbstractStream, Output pOutput As %Stream.Object, pPersonType As %String) as %Status
Create or replace
method deletePerson(pInput As %Library.AbstractStream, Output pOutput As %Stream.Object, pPersonType As %String, pKeyField As %String, pKeyVal As %String) as %Status
method retrievePerson(pInput As %Library.AbstractStream, Output pOutput As %Stream.Object, pPersonType As %String, pKeyField As %String, pKeyVal As %String, pGetField As %String = "") as %Status
Retrieve
method updatePerson(pInput As %Library.AbstractStream, Output pOutput As %Stream.Object, pPersonType As %String, pKeyField As %String, pKeyVal As %String) as %Status
Update: For given service, replaces primary Person or Person with given name

Inherited Members

Inherited Properties

Inherited Methods

FeedbackOpens in a new tab