Bulk update resource inventories
/rest/ofscCore/v1/resources/custom-actions/bulkUpdateInventories
This operation creates, updates, or deletes inventories of multiple resources in a single call. Only inventories with status as 'resource' are created, deleted, or updated. Inventories with status as 'installed' or 'deinstalled' are ignored. Each resource pool is processed independently - inventory will not be moved between different resources. To "move" a piece of inventory it is necessary to specifically create it in one resource pool and remove from another.
Error Handling:
- If the request size is greater than 5 MB, then the API fails with the HTTP status '413 Request entity too large' error.
- If the swagger validation fails, then the entire request fails with the HTTP status '400 Bad Request' error. Examples of such cases are:
- A required field is not specified.
- The request is not a valid JSON.
- The operation returns HTTP status '200 OK', even if individual inventories are not created for some reason. Verify the response to identify the operations that succeeded and the operations that failed. Examples of such cases are:
- The resource ID does not exist
- The resource does have inventories (not a technician).
- The inventory type does not exist.
- An invalid value is specified for an 'enum' custom property.
- A string value is specified for a custom property having data type as integer.
Permissions:
The permissions 'Core API : Resource' and 'Core API : Inventory' have to be set to 'ReadWrite' for this API to work.
Request
objectBulk update resource inventories request schema-
resources(required):
array Resources
Title:
ResourcesAn array of resource IDs and their related inventory information.
arrayResources-
Array of:
object Resource
Title:
Resource
objectResource-
identifySerializedInventoryBy:
string
Title:
Identify Serialized Inventory ByAllowed Values:[ "serialNumber", "typeAndSerial", "typeAndModelAndSerial" ]This field determines the key for identifying serialized inventory within a resource pool. The possible values of this field are:- serialNumber - When serialNumber is the only field required for identifying serialized inventories for a particular resource. This is the default value.
- typeAndSerial - When two fields (inventoryType + serialNumber) are used as the key for identifying serialized inventories for a particular resource.
- typeAndModelAndSerial - When three fields (inventoryType + model + serialNumber) are used as the key for identifying serialized inventories for a particular resource. The model value is stored in a custom property, which is configured for each inventory type. If inventory type was not provided, the model value is considered as empty.
-
inventories(required):
array Inventories
Title:
InventoriesAn array containing inventory objects. If this array is empty and the 'operationType' is 'replace', then all the existing inventories for the specified resource are erased. -
inventoryPropertiesUpdateMode:
string
Title:
Inventory Properties Update ModeAllowed Values:[ "keepProperties", "eraseProperties" ]The processing mode for updating the properties of each inventory item in the 'inventories' array. The possible values of this parameter are:
- keepProperties: The specified inventory properties are updated and the properties that are not specified are retained.
- eraseProperties: The specified inventory properties are replaced and the properties that are not specified are erased. This is the default value of the parameter.
-
operationType:
string
Title:
Operation TypeAllowed Values:[ "update", "replace" ]The type of the operation. The possible values of this parameter are:- replace - Existing inventories that are not specified in the request are deleted. Inventories that are specified in the request and exist in Oracle Field Service are updated. Inventories that are specified in the request but do not exist in Oracle Field Service are added. This is the default value.
- update - Existing inventories that are not specified in the request are not deleted. Inventories that are specified in the request and exist in Oracle Field Service are updated. Inventories that are specified in the request but do not exist in Oracle Field Service are added.
-
resourceId(required):
string
Title:
Resource IDMinimum Length:1The resource ID in the external system.
arrayInventories-
Array of:
object Inventory
Title:
Inventory
objectInventory-
inventoryType:
string
Title:
Inventory TypeThe label of the inventory type as defined in Oracle Field Service.- For non-serialized inventories, this parameter along with the model is used as the key to determine the existing inventory that is replaced.
-
quantity:
number
Title:
QuantityThe quantity of the non-serialized inventory.- For serialized inventories, the value of this parameter is set to 1.
- For non-serialized inventories, this parameter is saved. The value can be positive, negative, or zero.
-
serialNumber:
string
Title:
Serial NumberThe serial number of the inventory.- For serialized inventories, this is the unique key (or a part of the unique key along with other fields) of an inventory for a particular resource. This key is determined by the value of the 'identifySerializedInventoryBy' parameter.
- For non-serialized inventories, the value of this parameter can be specified but it does not hold any meaning.
Response
- application/json
200 Response
objectBulk Update Resource Inventories Response Schema-
created:
integer
Title:
CreatedThe number of inventories created by the API call. -
deleted:
integer
Title:
DeletedThe number of inventories deleted by the API call. -
itemsFailed:
integer
Title:
Items FailedThe number of items of the 'resources' array in the request that failed. -
results:
array Results
Title:
ResultsThe array of results. Each item in the 'resources' array in the request has a corresponding item in the 'results' array. The 'results' array items are in the same order as the 'resources' array items. -
updated:
integer
Title:
UpdatedThe number of inventories updated by the API call.
arrayResults-
Array of:
object Result
Title:
Result
objectResult-
created:
integer
Title:
CreatedThe number of inventories created for the specific resource. -
deleted:
integer
Title:
DeletedThe number of inventories deleted for the specific resource. -
errors:
array Errors
Title:
ErrorsThis field is returned only if any item fails. It contains human-readable description of the error such as type, title, HTTP status, and so on. -
resourceId:
string
Title:
Resource IDThe resource ID for which the inventories were updated, created, or deleted. -
updated:
integer
Title:
UpdatedThe number of inventories updated for the specific resource.
arrayErrorsobject-
detail:
string
The detailed description of this error.
-
status:
string
The HTTP status code of this error.
-
title(required):
string
The brief description of this error.
-
type(required):
string
The URL of the web page containing more details about this error.
Default Response
object-
detail:
string
The detailed description of this error.
-
status:
string
The HTTP status code of this error.
-
title(required):
string
The brief description of this error.
-
type(required):
string
The URL of the web page containing more details about this error.
Examples
The following example shows how to create or update resource inventory in bulk for the specified resources with the specified inventories by submitting a POST request on the REST resource using cURL:
cURL command Example
curl -s -u "<CLIENT-ID>@<INSTANCE-NAME>:<CLIENT-SECRET>" --url "https://<instance_name>.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/custom-actions/bulkUpdateInventories" -X POST -d '
{
"resources": [
{
"resourceId": "11102",
"inventories": [
{
"inventoryType": "NORMAL",
"serialNumber": "XA1234567892",
"testpropInvString" : "Blarg"
},
{
"inventoryType": "RG6BLK",
"inventory_model": "Z222",
"testpropInvString" : "Blarg 2",
"quantity": 8
},
{
"inventoryType": "RG6BLK",
"inventory_model": "X333",
"quantity": 5
}
]
},
{
"resourceId": "11105",
"inventories": [
{
"inventoryType": "xx",
"serialNumber": "XA1234567892",
"testpropInvString" : "Blarg"
},
{
"inventoryType": "RG6BLK",
"inventory_model": "Z222",
"testpropInvString" : "Blarg 2",
"quantity": 8
},
{
"inventoryType": "RG6BLK",
"inventory_model": "X333",
"quantity": 5
}
]
}
]
}'Response Header Example
The following shows an example of the response header.
HTTP/1.1 200 OK Server: nginx/1.2.7 Date: Mon, 18 Dec 2017 02:20:33 GMT Content-Type: application/json; charset=utf-8
Response Body Example
The following shows an example of the response body in JSON format, where one request item was processed successfully while the other request item failed:
{
"created": 0,
"updated": 3,
"deleted": 0,
"itemsFailed": 1,
"results": [
{
"resourceId": "11102",
"created": 0,
"updated": 3,
"deleted": 0
},
{
"resourceId": "11105",
"error": {
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10",
"title": "Conflict",
"status": "409",
"detail": "Invalid value of field 'inventories/0/inventoryType'. Value: 'xx'"
}
}
]
}