Class: SCIMMY.Messages.ListResponse

SCIM List Response Message

Summary:
  • Formats supplied service provider resources as ListResponse messages, handling pagination and sort when required.

The ListResponse class creates a SCIM ListResponse message for a supplied set of resources, and automates pagination and sorting of the included set. It is used internally by the read() method in each of SCIMMY's Resource classes when requesting a list of resources matching a given query, and in the apply() instance method of the SearchRequest message class.

Tip:
When using the User and Group resource classes, their instance read() methods will wrap the set of matching query results in a ListResponse instance. This happens automatically when retrieving multiple resources, meaning their egress handlers need only return the array of matching resources, not a ListResponse instance of their own.

Usage

Instantiate a new SCIM List Response Message with relevant details

                    
                        new SCIMMY.Messages.ListResponse(request, paramsopt)
                    
                
Parameters:
Name Type Description
request SCIMMY.Messages.ListResponse SCIMMY.Types.Schema[]

contents of the ListResponse message, or items to include in the list response

paramsopt ~ListConstraints

parameters for the list response (i.e. sort details, start index, and items per page)

Properties
Name Type Default Description
sortByopt String
                        
                    

the attribute to sort results by, if any

sortOrderopt String
                        "ascending"
                    

the direction to sort results in, if sortBy is specified

startIndexopt Number
                        1
                    

offset index that items start from

countopt Number
                        20
                    

alias property for itemsPerPage, used only if itemsPerPage is unset

itemsPerPageopt Number
                        20
                    

maximum number of items returned in this list response

totalResultsopt Number
                        
                    

the total number of resources matching a given request

Properties:
Name Type Description
schemas SCIMMY.Messages.ListResponse.id[]

list exclusively containing the SCIM ListResponse message schema ID

Resources SCIMMY.Types.Schema[]

resources included in the list response

totalResults Number

the total number of resources matching a given request

startIndex Number

index within total results that included resources start from

itemsPerPage Number

maximum number of items returned in this list response

Examples:
Basic usage with no constraints
// Retrieve the list of resources from somewhere, and pass it to the ListResponse constructor
const resources = [{id: "1", userName: "AdeleV"}, {id: "2", userName: "GradyA"}];
const response = new SCIMMY.Messages.ListResponse(resources);
Basic usage with specified total results
// Retrieve the list of resources from somewhere...
const resources = [{id: "1", userName: "AdeleV"}, {id: "2", userName: "GradyA"}];
// ...and separately retrieve the total number of matching results
const totalResults = 1005;

// Instantiate the list response with the resources array, specifying totalResults
const response = new SCIMMY.Messages.ListResponse(resources, {totalResults});
Advanced usage with manipulation of array length
// Retrieve the list of resources from somewhere...
const resources = [{id: "1", userName: "AdeleV"}, {id: "2", userName: "GradyA"}];
// ...and set the length of the list to match the desired total
resources.length = 1005;

// Instantiate the list response with the (mostly) sparse resources array
const response = new SCIMMY.Messages.ListResponse(resources, {itemsPerPage: 2});

Members

(static) id: "urn:ietf:params:scim:api:messages:2.0:ListResponse"

SCIM List Response Message Schema ID

Type:
{"urn:ietf:params:scim:api:messages:2.0:ListResponse"}

Type Definitions

ListConstraints

ListResponse sort and pagination constraints

Type:
{Object}
Properties:
Name Type Default Description
sortByopt String
                        
                    

the attribute to sort results by, if any

sortOrderopt String
                        "ascending"
                    

the direction to sort results in, if sortBy is specified

startIndexopt Number
                        1
                    

offset index that items start from

countopt Number
                        20
                    

maximum number of items returned in this list response