Create Or Modify
Introduction
The endpoints of this service allow createation or modification of the object instances. It is required to configure the service like for the views.
Configuration
Each action is associated to an identifier and a configuration JSON.
JSON example
{
"objectname": "name of the object",
"create": true, // indicates if new instances creation is allowed
"patch": false, // indicates if partial modification of properties is allowed
"workflow": true, // indicates if workflow modification (per action) is allowed
"props": { // List of modifiable properties and their configurations
"name of the property": null
}
}
Properties and sections
objectname: String - Name of the object (type)
description: String - Short description of action
props: Section properties An object which properties are property names that should be exported. It is possible to configure some options, and some formating action or value validation. But it has limitation for a complex rule, the trigger should be used. Cf. hereafter for the configuration detail.
create: A boolean to allow creation
patch: A boolean to allow the modification of some specific properties (by default all configured properties shall be filled)
workflow: A boolean that allows to modify the workflow (thru workflow actions)
lock: A boolean that allows to lock or unlock objects
since 11.11reportprops: an array of properties of the created object that you want to include in the response
since 11.12updatequery: An optional selection request following JSON type specific language used within "create or update" mode. The values of the key properties (or others) are configurable in the query by the syntax ${<variable identifier>}:
to reference a key property, use its name as identifier
example: ${name}to reference the associated property in the clause, simply use a question mark (?)
example: ${?}to reference any parameter of the http request, prefix the name of parameter with "par:".
example: ${par:p_activated}
For example:
{ "product": "${?}", "businessunit": "${?}" }
Properties configuration
It is possible to configure the assignment of a value to a property by defining a configuration object for the property.
If no configuration is defined, a null object shall be defined:
Depending on the data types, several configuration can be done: the indicators which are not corresponding to the available properties will be ignored. The configuration is split in 4 sections:
check: verification
pattern: allows the indication of a regular expression that value must verify (works with character string: text, data/word, sentence, html, image access path and file path (in this case backslashes should be considered as slashes) For example:
min: allows the definition of a minimal value included in the interval (works with numbers: integer, floating, currencies) For example:
max: allows the definition of a maximal value included in the interval (works with numbers: integer, floating, currencies) For example:
values: Allows the indication of a list of value (table), among which the assigned value must be available (works for character string and numbers) For example:
format: formating
trim: allows deletion of useless white spaces
right: delete right white spaces For example:
left: delete left white spaces For example:
true: delete right and left white spaces For example:
Â
pattern: a regular expression
replace: the replacing string
For example, to put all numbers between parenthesis except if they already are:
case: to change the case
upper: to go uppercase
lower: to go lowercase
sentence: to have the full sentence in lowercase and only the first letter in uppercase
word: to have all characters in lowercase except the first letter of each word that will be in uppercase
i18n: localization
By default whenever a localized property is modified, the property corresponding to the language of the request is modified (lang parameter).
For example, if a property value (i18n), value_fr (i18n of value), value_en (i18n of value)If the request local is en
If we modify value, then value_en is modified
If we modify value_fr, then value_en is modified
This configuration property allows to modify this default behavior.
true: the hereinabove rules are applied
false: the specified property is modified. If we keep the same examples:
(3) If we modify value, then value is modified
(4) If we modify value_fr, then value_fr is modified
So if false then we only modify specified property else we check if the property is in the correct local; if true the correct local is directly modified; if default we raise an exception.
since 11.11byvalue: a boolean to enabled relational relationships assignation or creation by value (see create). Default to false. When this option is set to true, for relational properties, values can be passed instead of object identifiers. The corresponding object is searched for and if it does not exist, it is created with the specified value as its name. Finally, it is the object identifier that is affected. Use formatting options to limit the creation of duplicates.
since 11.11valueProperty: if relational relationships assignation is selected, indicates the name of property used to find the object corresponding to the value. it is possible to specify an array of properties if the object must be created or selected in relation to several values: in that case, the value of the parameter must be a json object, with all properties and their respective value.
since 11.11create: a boolean to enabled creation by value (see byvalue). Default to true.
since 11.18lockCaptureTimeout: the timeout value to capture a lock used with "by value" mode to handle simultaneous access (in seconds)
since 11.18lockAcquireTimeout: the timeout value to acquire a lock used with "by value" mode to handle simultaneous access (in seconds)
since 11.11pathseparator: a regular expression to break the paths into names. Default is \ (example of value: Europe \ Great Britain \ England \ (Greater) London \ City of London \ Hampstead).When assigning by value (see byvalue), it is possible to manipulate tree-like data by specifying a path, consisting of several successive names. The division of the value into names of the different objects is done according to this regular expression.
For example:
force: a boolean to force the modification of status property. By default, it is not possible to modify the assignment of position 7 property (status): a workflow action is required. But for ascending compatibility with the former workflow system, it is possible to modify the status by a value assignment via this property.
since 11.12key: a boolean to set this property as key for the "create or update" mode. This feature is not yet supported for children or collection properties.
EndPoints
There are seven endpoints available
To modify, partially modify or create
To modify a workflow by an action
To get the list of workflow actions
To get the list of available actions
To get object locks
To lock objects
To unlock objects
EndPoint: modify
since 11.14
Â
since 11.12
Â
Legacy endpoint:
Â
Supported methods: PUT, PATCH
The difference between the two methods is that PUT imposes the modification of all configured properties whereas PATCH allows the modification of some properties
Parameters
actionName: Character string, action identifier
id (or form_id): Identifier of the current instance
prop_<x>: the value to assign to the x property (cf. hereafter properties values assignment)
since 11.12rawValues Boolean - Indicates if we apply the localization (false by default) in reported properties
since 11.12headers: Boolean - Indicates if headers are required (Cf. hereafter, response format) (false by default)
since 11.12report: Boolean - Indicates if properties of the created object must be reported (if configured so) (true by default)
Security
The update action of the RESTAPI domain allows the management of the endpoint call authorisation.
There are two parameters:
surfer: surfer
actionName: the action identifier
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
404 | 404/200 | Unknown action |
403 | 403/201 | Forbidden modification |
403 | 403/202 | Forbidden partial modification |
403 | 403/204 | The user grants doesn’t allow to modify an object |
403 | 403/205 | The user grants doesn’t allow to modify this object |
403 | 403/206 | Forbidden to modify a property |
404 | 404/900 | Object not found |
400 | 400/900 | Missing content |
since 11.11 400 | 400/900 | Not allowed value |
since 11.11 400 | 400/900 | Not allowed to creae value |
since 11.11 500 | 500/901 | Cannot create value (server error) |
EndPoint: create
since 11.14
since 11.12
Legacy endpoint:
Supported method: POST
Parameters
actionName: Character string, action identifier
prop_<x>: The value assigned to the x property (cf. hereafter properties values assignment)
since 11.11
rawValues Boolean - Indicates if we apply the localization (false by default) in reported properties
since 11.11
headers: Boolean - Indicates if headers are required (Cf. hereafter, response format) (false by default)
since 11.11
report: Boolean - Indicates if properties of the created object must be reported (if configured so) (true by default)
Response format
The response to the endpoint call contains the identifier of the newly created resource (field createdId).
Security
The create action of RESTAPI domain allows to manage the endpoint call authorization.
There are two parameters:
surfer: surfer
actionName: the action identifier
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
404 | 404/200 | Unknown action |
403 | 403/200 | Forbidden creation |
403 | 403/202 | Forbidden partial modification |
403 | 403/203 | The user grants doesn’t allow to create an object |
400 | 400/900 | Missing content |
since 11.11 400 | 400/900 | Not allowed value |
since 11.11 400 | 400/900 | Not allowed to creae value |
since 11.11 500 | 500/901 | Cannot create value (server error) |
EndPoint: Apply workflow action
since 11.14
since 11.12
Â
Legacy endpoint:
Â
Supported method: PATCH
Parameters
actionName: Character string, action identifier
id (or form_id): Identifier of current instance
action: Identifier or name of the action to be applied
Security
The workflow_do action of RESTAPI domain allows the management of the endpoint call authorization.
There are two parameters:
surfer: surfer
actionName: the action identifier
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
404 | 404/200 | Unknown action |
403 | 403/207 | Forbidden workflow modification |
403 | 403/208 | Forbidden workflow action |
EndPoint: list of available workflow actions
since 11.14
since 11.12
Â
Legacy endpoint:
Â
Supported methods: GET, HEAD
Parameters
actionName: Character string, action identifier
id (or form_id): Instance identifier for which we want to know the available actions
rawValues: Boolean that indicates if we need to localize terms (false by default)
onlyAllowed: Boolean, optional, to get only allowed action by the user (false by default)
Response format
The workflow_actions action of RESTAPI domain allows the management of the endpoint call authorization.
There are two parameters:
surfer: surfer
actionName: the action identifier
EndPoint: obtain the status of object locks
since 11.14
since 11.12
Â
Legacy endpoint:
Â
Supported methods: GET, HEAD
Parameters
actionName: Character string, action identifier
id (or form_id): The identifier of the instance to be locked (multiple possible values)
Response format
Security
The locks_get action of RESTAPI domain allows the management of the endpoint call authorization.
There are two parameters:
surfer: surfer
actionName: the action identifier
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
403 | 403/210 | Forbidden action |
Â
EndPoint: put locks on objects
since 11.14
since 11.12
Â
Legacy endpoint:
Â
Supported methods: POST
Parameters
actionName: Character string, action identifier
id (or form_id): The identifier of the instance to be locked (multiple possible values)
duration: Number, optional, lock duration in seconds
Response format
in case of error, the status is error and info is the error message. The current lock status is null if the error occurred when querying the current lock status.
if the instance was not locked and becomes locked, the status is locked and the info is the name of the owner of the lock (the user who is invoking the service)
if the instance was already locked by the calling user, the lock is extended, and the status is lock extended
if the instance was locked but by another user, the status is already locked and info is the current owner’s name
Security
The lock action of RESTAPI domain allows the management of the endpoint call authorization.
There are two parameters:
surfer: surfer
actionName: the action identifier
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
403 | 403/211 | Forbidden lock action |
EndPoint: remove locks on objects
since 11.14
since 11.12
Â
Legacy endpoint:
Â
Supported methods: DELETE
Parameters
actionName: Character string, action identifier
id (or form_id): The identifier of the instance to be locked (multiple possible values)
Response format
in case of error, the status is error and info is the error message. The current lock status is null if the error occurred when querying the current lock status.
if the instance wasn’t locked, the status is not locked and the info is null.
if the instance was locked by the calling user, the status is unlocked the info is null
if the instance was locked but by another user, the status is not owner and info is the current owner’s name
Security
The unlock action of RESTAPI domain allows the management of the endpoint call authorization.
There are two parameters:
surfer: surfer
actionName: the action identifier
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
403 | 403/210 | Forbidden lock view |
403 | 403/211 | Forbidden lock action |
403 | 403/212 | Forbidden unlock action |
403 | 500/200 | Cannot lock object |
EndPoint: list of available actions
since 11.12
Legacy endpoint:
Â
Supported methods: GET, HEAD
Parameters
actionName: Character string, an option regular expression filter (by default, all actions are accessible)
headers: Boolean indicates if headers are required or not (cf. hereafter, response format) (false by default).
Response format
Security
The catalog action of RESTAPI domain allows the management of the endpoint call authorization.
There are two parameters:
surfer: surfer
endPoint: the endpoint identifier, with update value.
Errors codes
HTTP Code | API Code | Definition |
---|---|---|
403 | 403/209 | Actions catalog not reachable |
Assigning property values
To assign a value to a property, please pass the prop_ prefixed property name as a parameter, as well as its value.
For instance, to assign the value Example to the name property: prop_name=Example
Character strings
Just indicate the value. For a null value, we shall use #NULL.
Examples:
Numbers
Just mention the value. For a float number, we shall use decimal point (.) to set the decimal position. For a null value, use a void value.
Examples:
Â
booleans
True stands for the true logical value, false for the false one or nothing for null.
Examples:
Â
dates
Dates are passed either as timestamps (UTC unix time), or in ISO format
Examples:
Â
children (object)
Children are referenced through their ID. It is not possible to assign a non existing object.
Example:
Â
multiple children (array)
To assign several values we shall mention the parameter on several times.
Examples:
files
Binary file content is passed in multipart mode (multipart/form-data). It is possible to indicate a replacement name for the file by passing it as a parameter.
We can to follow through a download by indicating an identification number via the parameter. The appropriate method to follow-up download progress is similar to the one detailed here.
since 11.12 It is possible also to pass an URL as value. To set the name, pass a json value like in this example :
Create or update mode
It is possible to configure an action to operate in "create or update" mode. By default, a POST on the endpoint "create" creates a new object instance and a PUT on the endpoint "modify" modifies a time point designated by its identifier (parameter id).
With "create or update" mode, with all endpoints, we first determine if the object exists: if it exists, it is modified, otherwise it is created.
This mode is activated as soon as a property is designated as key, with the key configuration property. We search for the object instance (or instances) whose key values are equal to those passed as parameters: if it exists, it is modified, otherwise a new instance is created.
It is possible to use a specific query to search for the object instance by the updatequery configuration property.