Skip to main content

%pkg.isc.rest.model.resource

abstract class %pkg.isc.rest.model.resource extends %Library.RegisteredObject, %pkg.isc.rest.model.iSerializable

Base class for all REST resources

Method Inventory

Parameters

parameter DEFAULT;
Set to 1 to treat this resource as the default for its name. This permit flexible matching on MEDIATYPE for GET requests; e.g., given MEDIATYPE=application/json, a GET request for this resource name will match if Accept is set to */* or application/*
parameter MEDIATYPE = application/json;
Content-Type implemented in this class Subclasses MAY override this
parameter RESOURCENAME;
Name of the resource at the REST level Subclasses MUST override this
parameter SecurityResource;
Security resource used to protect this REST resource.
If provided, then any READ or QUERY operations require READ access to the resource and any Create, Update or Delete operations require WRITE access to the resource.
This parameter is used in the default implementation of CheckPermission() below. If more advanced permission checking is needed, the method can be overridden.

Methods

classmethod CheckPermission(pID As %String, pOperation As %String, pUserContext As %RegisteredObject, ByRef URLParams) as %Boolean
Checks the user's permission for a particular operation on a particular record. pOperation may be one of the macros of the form $$$Operation* present in %pkg.isc.rest.general.inc.
If this method returns 0, the corresponding dispatch class will return a 403 Unauthorized status when the operation is invoked.
pUserContext is supplied by GetUserContext().
abstract classmethod DeleteModelInstance(pID As %String) as %Boolean
Deletes an instance of this model, based on the identifier pID
abstract classmethod GetCollection(ByRef params, selectMode As %Integer)
Called by the handler when serving plural get requests.

In the simplest case, the Resource is a Proxy and params are just query parameters for querying a table. Note: This method should handle exporting JSON to the current device.
abstract classmethod GetModelInstance(args...) as %pkg.isc.rest.model.resource
Returns an instance of this model, based on the arguments supplied.
abstract classmethod ModifyOpenAPIInfo(ByRef schemas As %ListOfObjects, ByRef endpoints As %pkg.isc.rest.openAPI.model.paths)
Modify the autogenerated OpenAPI Specification objects for this class by changing the values of the passed ByRef parameters @Argument schemas: List of %pkg.isc.rest.openAPI.model.schema @Argument endpoints: Array of endpoint URL -> %pkg.isc.rest.openAPI.model.pathItem (%pkg.isc.rest.openAPI.model.paths) Sample use cases: - Modify resource schema descriptions - Add additional ISC_* fields to the resource schemas - Correct resource schemas for classes that use custom JSON generation code - Remove non-desired endpoints from output - Provide alternate schemas for endpoint input / output (ie. in the case of %DynamicObject use) - Add documentation for non-standard endpoints Note: Endpoints can be removed from the endpoints array as desired, however schemas should not be removed from the schemas array.
abstract method SaveModelInstance(pUserContext As %RegisteredObject)
Saves the model instance.
classmethod Supports(pOperation As %String, pType As %String(VALUELIST=",instance,class"), pRequest As %CSP.Request = $$$NULLOREF) as %Boolean
Checks if the particular operation is supported for this resource.
Look at documentation of SupportsDefault() for default behavior of this method.
If the method returns 0, the corresponding dispatch class will return a 404 Not Found status when the operation is invoked.
NOTE: This method runs on EVERY request so should be quick, lightweight checks to prevent performance bottlenecks.
pOperation may be one of the macros of the form $$$Operation* present in %pkg.isc.rest.general.inc.
pType is the type of the operation (instance-level on a particular record or class-level).
pRequest is the request object in an HTTP context. NOTE: MUST check that this is an object before using it as it may be passed as a NULL OREF in some cases.
final classmethod SupportsDefault(pOperation As %String, pType As %String(VALUELIST=",instance,class"), pRequest As %CSP.Request = $$$NULLOREF) as %Boolean
Default implementation of Supports() which acts as a wrapper around this method.
By default, the behavior is to support all operations that have their corresponding methods implemented i.e. the methods are not abstract.

Inherited Members

Inherited Methods

Subclasses

FeedbackOpens in a new tab