Bulk Update¶
Action | bulk_update (1) |
---|---|
title | First task: Obtain the URL and schema needed to construct the payload to modify the resource. |
method | GET |
URL | /api/<resource_type>/<resource_name>/bulk_update/ |
Parameters | hierarchy=[hierarchy], format=json |
Response | Returns: POST call that is used to update the instances of resource schema that is used to create POST payload. |
support_async | false |
class | update |
Action | bulk_update (2) |
---|---|
title | Second task: Perform the bulk modify on the required list of instances each with [pkid] with the payload constructed from the schema in the first task. |
method | POST |
URL | /api/<resource_type>/<resource_name>/bulk_update/ |
Parameters | hierarchy=[hierarchy], format=json |
Payload | Contains update data and instance pkids to update. |
Use the GET request to obtain a list of instance pkids to select for the bulk update:
GET /api/<resource_type>/<resource_name>/?hierarchy=[hierarchy]&format=json
As an example, the request below shows the required details for a particular model. (Using variables [hierarchy], [pkid1], [pkid2])
Request for POST call and schema:
GET /api/data/AccessProfile/bulk_update/
?hierarchy=[hierarchy]
&schema_rules=true
&format=json
&schema=1
Response snippet - POST call:
"bulk_update": {
"class": "update",
"href": "/api/data/AccessProfile/bulk_update/?hierarchy=[hierarchy]",
"method": "POST",
"support_async": true,
"title": "Bulk Modify"
}
Response snippet - schema:
"schema": {
"$schema": "http://json-schema.org/draft-03/schema",
"properties": {
"description": {
"description": "A description for the Access Profile.",
"required": false,
"title": "Description",
"type": "string"
},
"full_access": {
"description": "Enabling this flag, grants the user full
system access.",
"required": false,
"title": "Full Access",
"type": "boolean"
},
"miscellaneous_permissions": {
"description": "The list of miscellaneous operations permitted by
this Access Profile.",
"items": {
"choices": [
{
"title": "",
"value": ""
}
],
"type": "string"
},
"required": false,
"title": "Miscellaneous Permissions",
"type": "array"
},
"name": {
"description": "The name that is given to the Access Profile.",
"required": false,
"title": "Name \*",
"type": "string"
},
"type_specific_permissions": {
"description": "The list of types that are permitted by
this Access Profile.",
"items": {
"properties": {
"operations": {
"description": "The operations that are permitted by this Access
Profile for the given type.",
"items": {
"choices": [
{
"title": "",
"value": ""
}
],
"type": "string"
},
"required": false,
"title": "Permitted Operations \*",
"type": "array"
},
"type": {
"choices": [],
"description": "The type that is permitted by this Access Profile.
This field supports the use of the * wildcard.",
"format": "uri",
"required": false,
"target": "/api/choices/?hierarchy=[hierarchy]&format=json",
"target_model_type": "",
"title": "Permitted Type \*",
"type": "string"
}
},
"type": "object"
},
"required": false,
"title": "Type Specific Permissions",
"type": "array"
}
},
"schema_version": "0.1.8",
"type": "object"
},
Example POST request to carry out the update:
POST /api/data/AccessProfile/bulk_update/
?hierarchy=[hierarchy]
&nowait=true
&format=json
Payload example - bulk updating the description of instances having pkid1, pkid2 with the string “profile”:
{"data":{"description":"profile"},
"meta":{
"references":{
"form_href":"/api/data/AccessProfile/bulk_update/
?hierarchy=[hierarchy]
&schema=
&schema_rules=true"
}
},
"request_meta":{
"hrefs":[
"/api/data/AccessProfile/[pkid1]",
"/api/data/AccessProfile/[pkid2]"
]
}
}