Toggle menu

userLinking_userLinkTypes

This API is intended only for use by GOSS developers as the first stage in user linking product development. It is liable to change and should not be incorporated into production environments with real users.

This API manages the types of links that can be created between users. No userLinkTypes exist in the database until they have been created.

When a userLinkType is created an ID is returned in the response. This ID is used in all other methods and when managing links between users with userLinking_userLinks.

Authentication

All requests need the username and password of an iCM user. These can be provided directly or via an API key's "default credentials".

See End Point this Object for information about supplying an API key when calling a worker from an End Point, API Server Security for information about keys and default credentials, and the methods below for examples.

Name and ID

All link types have a name, set when the type is created, and an ID generated by the worker.

Direction and Cardinality

When you create a link type you must also set its cardinality. Then, when you create a link between users, you set the link type and the direction of that link (either to or from the user).

Once users are linked by a particular type and direction, attempts to create additional links to or from the same user of the same type are checked against the cardinality of existing links for conflicts.

The four cardinality types are:

ONE_TO_ONE - A user may have a single one-to-one link of a particular type linking to it and from it

One to One Links
 
userA cannot link to userD as it already has a one-to-one link of this type from it. userC can link to userA. userB cannot link to or from anyone else

ONE_TO_MANY - A user may have a single one-to-many link of a particular type linking to it, and any number linking from it

One to Many Links
 
userA can link to many users. userD cannot link to userC using this one-to-many type as userC already has a link from userA

MANY_TO_ONE - A user may have a single many-to-one link of a particular type linking from it, and any number linking to it

Many to One Links
 
Many users can link to userA. userC cannot link to userD as it is already linked to userA by this many-to-one link

MANY_TO_MANY - A user can have any number of these links to it and/or from it

Logging

Creating, deleting and updating link types is recorded in iCM's security log.

Methods

Note that all request parameters are passed to the method in a "payload" object. See the examples below.

userLinking_userLinkTypes_create

Creates a userLinkType.

Request Parameters

NameTypeDescription
nameStringRequired. A name for this userLinkType
cardinalityStringRequired. One of ONE_TO_ONE, ONE_TO_MANY, MANY_TO_ONE, MANY_TO_MANY
commentStringOptional. An optional comment

function(params, credentials) {
    let linkType = this.callWorkerMethod("icmapi", "userLinking_userLinkTypes_create", {
        payload: {
            name: "testManyToOne",
            cardinality: "MANY_TO_ONE",
            comment: "Many to one testing"
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return linkType;
}

Response - Success

NameTypeDescription
idIntegerThe ID of the created userLinkType
nameStringAs supplied
cardinalityStringAs supplied
commentStringAs supplied

{
    "id": 743,
    "result": {
        "id": 8,
        "name": "testManyToOne",
        "cardinality": "MANY_TO_ONE",
        "comment": "Many to one testing"
    },
    "jsonrpc": "2.0"
}

Response - Error

Returned when the name already exists.

{
    "id": "_1",
    "error": {
        "code": -32602,
        "data": "Conflict",
        "message": "Conflict"
    },
    "jsonrpc": "2.0"
}

userLinking_userLinkTypes_delete

Deletes a userLinkType. Note that when a userLinkType is deleted, all links between users of this type are also deleted.

Request Parameters

NameTypeDescription
idIntegerRequired. The ID of the userLinkType to delete

function(params, credentials) {
    let linkType = this.callWorkerMethod("icmapi", "userLinking_userLinkTypes_delete", {
        payload: {
            id: 10
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return linkType;
}

Response - Success

None.

{
    "result": null,
    "id": "_1",
    "jsonrpc": "2.0"
}

Response - Error

Returned when the userLinkType couldn't be found.

{
    "id": "_1",
    "error": {
        "code": -32602,
        "data": "NotFound",
        "message": "NotFound"
    },
    "jsonrpc": "2.0"
}

userLinking_userLinkTypes_get

Returns a single userLinkType by ID.

Request Parameters

NameTypeDescription
idIntegerRequired. The ID of the userLinkType

function(params, credentials) {
    let linkType = this.callWorkerMethod("icmapi", "userLinking_userLinkTypes_get", {
        payload: {
            id: 8
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return linkType;
}

Response - Success

The requested userLinkType.

NameTypeDescription
idIntegerThe ID of the userLinkType
nameStringThe name
cardinalityStringThe cardinality
commentStringThe comment

{
    "id": 743,
    "result": {
        "id": 8,
        "name": "testManyToOne",
        "cardinality": "MANY_TO_ONE",
        "comment": "Many to one testing"
    },
    "jsonrpc": "2.0"
}

userLinking_userLinkTypes_getAll

Gets all userLinkTypes that match the supplied filters and paging.

Request Parameters

NameTypeDescription
filtersObjectOptional. Not setting a filter (or providing an empty filter object) will return all userLinkTypes
filters.namesArray <string>The names of the userLinkTypes to return
paginationObjectOptional. The start position and length of results to return
pagination.startIntegerThe start position (zero based)
pagination.lengthIntegerThe number to return

This example returns the first three userLinkTypes.

function(params, credentials) {
    let getAll = this.callWorkerMethod("icmapi", "userLinking_userLinkTypes_getAll", {
        payload: {
            filters: {},
            pagination: {
                start: 0,
                length: 3
            }
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return getAll;
}

This example returns the named link types.

function(params, credentials) {
    let getAll = this.callWorkerMethod("icmapi", "userLinking_userLinkTypes_getAll", {
        payload: {
            filters: {
                names: ["timOneToMany", "timOneToOne"]
            },
            pagination: {}
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return getAll;
}

Response - Success

An array of userLinkTypes that match the filters and pagination, where each userLinkType has the following properties.

NameTypeDescription
idIntegerThe ID of the userLinkType
nameStringThe name
cardinalityStringThe cardinality
commentStringThe comment

{
    "id": 477,
    "result": [{
        "id": 4,
        "name": "timOneToMany",
        "cardinality": "ONE_TO_MANY",
        "comment": null
    }, {
        "id": 5,
        "name": "timOneToOne",
        "cardinality": "ONE_TO_ONE",
        "comment": "One to one test"
    }],
    "jsonrpc": "2.0"
}

userLinking_userLinkTypes_update

Updates an existing userLinkType. The payload is the same as that of create, with the addition of the ID of the userLinkType to update.

When updating the cardinality of a link type all existing user links are checked and the update will fail if the new cardinality would violate existing links.

Request Parameters

NameTypeDescription
idIntegerRequired. The ID of the userLinkType to update
nameStringRequired. A name for this userLinkType
cardinalityStringRequired. One of ONE_TO_ONE, ONE_TO_MANY, MANY_TO_ONE, MANY_TO_MANY
commentStringOptional. An optional comment

function(params, credentials) {
    let linkType = this.callWorkerMethod("icmapi", "userLinking_userLinkTypes_update", {
        payload: {
            id: 8,
            name: "new name",
            cardinality: "MANY_TO_ONE",
            comment: "new comment"
        }
    }, {
        options: {
            apiKey: "<Your API Key>"
        }
    });
    return linkType;
}

Response - Success

None.

{
    "result": null,
    "id": "_1",
    "jsonrpc": "2.0"
}

Response - Error

In this example the change to the cardinality would have caused a conflict with existing links between users.

{
    "id": "_1",
    "error": {
        "code": -32602,
        "data": "Conflict",
        "message": "Conflict"
    },
    "jsonrpc": "2.0"
}

Last modified on November 21, 2023

Share this page

Facebook icon Twitter icon email icon

Print

print icon