バッチ処理の実行
複数の操作を1つのHTTPリクエスト(バッチ・アクション)に結合して、パフォーマンスを向上させることができます。 リクエスト本文は、オブジェクトの配列であるparts
というフィールドを持つJSONオブジェクトです。 配列の各オブジェクトには次のものが含まれます:
-
一意のID
-
リソースへの相対パス
-
操作
-
(オプション)ペイロード
バッチ・リクエストを使用してカスタム処理を実行することもできます。 ただし、すべてのカスタム処理がバッチ・リクエストでサポートされていない場合があります。 サポートされていないカスタム処理の場合、バッチ・リクエストにこのエラーが表示されます: アクション {ACTION_NAME} は、バッチ実行に対して有効になっていません。
ノート:
バッチ・リクエストのペイロード内の1つの部分が失敗した場合、バッチ・アクションは基本的にすべてまたは1つのアクションであるため、他のすべての部分も暗黙的に失敗します。 特定のパーツがエラーのために失敗した場合は、エラーを含むパーツのみがレスポンスにリストされます。 エラーのない部品は、レスポンスにリストされません。 ただし、どの部品も処理されません。
バッチ・アクション・リクエストのJSONスキーマは次のとおりです:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"title": "Batch execution",
"description": "Group multiple requests together ('part').",
"definitions": {
"Part": {
"type": "object",
"allOf": [
{
"properties": {
"id": {
"type": "string",
"description": "An identification provided by the client to distinguish each part provided in the batch request."
},
"path": {
"type": "string",
"description": "Resource's location."
},
"operation": {
"type": "string",
"enum": [
"get",
"create",
"update",
"replace",
"delete"
],
"description": "The operation that will be performed."
},
"preconditionSucceeded": {
"type": "boolean",
"description": "This attribute is set in the batch response only when ifMatch or ifNoneMatch are provided in the request. It will be 'true' if the precondition (ifMatch/ifNoneMatch) was satisfied, otherwise 'false'."
},
"payload": {
"oneOf": [
{
"$ref": "resource-item.json",
"description": "The payload that will be used in the operation. Example: a resource instance should be provided in order to execute a 'create'."
},
{
"type": "null"
}
]
}
},
"required": [
"id",
"path",
"operation"
]
}
],
"anyOf": [
{
"properties": {
"ifMatch": {
"type": "string",
"description": "This attribute is analogous to the If-Match header. It represents a precondition to execute this operation. The value can be null (same effect of 'If-Match: *') or an array of resource versions."
}
}
},
{
"properties": {
"ifNoneMatch": {
"type": "string",
"description": "This attribute is analogous to the If-None-Match header. It represents a precondition to execute this operation. The value can be null (same effect of 'If-None-Match: *') or an array of resource versions."
}
}
}
],
"description": "Represents a request."
}
},
"properties": {
"parts": {
"type": "array",
"items": {
"$ref": "#/definitions/Part"
},
"description": "Array that represents multiple requests."
}
},
"required": [
"parts"
]
}
例: 調達エージェントの取得および調達エージェントの作成
このリクエストでは、調達エージェントを取得し、調達エージェントを作成します:
curl \
https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/ \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/vnd.oracle.adf.batch+json'
{
"parts": [
{
"id": "part1",
"path": "/procurementAgents/?q=AgentEmail='john.brown@example.com'",
"operation": "get"
},
{
"id": "part2",
"path": "/procurementAgents",
"operation": "create",
"payload": {
"Address" : [
{
"AgentId": 300100008259523,
"ProcurementBUId": 1016,
"Status": "Active",
"DefaultRequisitioningBU": null,
"DefaultRequisitioningBUId": null,
"DefaultPrinter": null
}
]
}
}
]
}
レスポンス本文には結果が含まれ、リクエストと同じメディア・タイプが使用されます。
{
"parts": [
{
"id": "part1",
"path": "/procurementAgents/?q=AgentEmail='john.brown@example.com'",
"operation": "get"
"payload" : {
"AssignmentId": 20000000000587,
"Agent": "Brown, John",
"AgentId": 8156,
"AgentEmail": "john.brown@example.com",
"ProcurementBU": "Vision Services",
"ProcurementBUId": 458,
"Status" : "Active",
"StatusCode" : "Y",
"DefaultRequisitioningBU" : null,
...
}
},
},
{
"id": "part2",
"path": "/procurementAgents",
"operation": "create",
"payload" : {
"AssignmentId" : 300100124649102,
"Agent" : "Johnson, Richard",
"AgentId" : 300100008259523,
"AgentEmail" : "richard.johnson@example.com",
"ProcurementBU" : "Vision Operations",
"ProcurementBUId" : 1016,
"Status" : "Active",
"StatusCode" : "Y",
"DefaultRequisitioningBU" : null,
"DefaultRequisitioningBUId" : null,
"DefaultPrinter" : null,
...
}
}
]
}
例: 既存の調達エージェントの取得と別の調達エージェントの更新
このリクエストでは、既存の調達エージェントを取得し、別の調達エージェントの詳細を更新します:
curl \
https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/ \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/vnd.oracle.adf.batch+json'
{
"parts": [
{
"id": "part1",
"path": "/procurementAgents/?q=AgentEmail='john.brown@example.com'",
"operation": "get"
},
{
"id": "part2",
"path": "/procurementAgents/20000000000613",
"operation": "update",
"payload": {
"Agent" : "Johnson, John",
"Status": "Inactive",
}
}
]
}
レスポンス本文には結果が含まれ、リクエストと同じメディア・タイプが使用されます。
{
"parts":[
{
"id":"part1",
"path":"/procurementAgents/?q=AgentEmail='john.brown@example.com'",
"operation":"get",
"payload" :{
"AssignmentId": 20000000000587,
"Agent": "Brown, John",
"AgentId": 8156,
"AgentEmail": "john.brown@example.com",
"ProcurementBU": "Vision Services",
"ProcurementBUId": 458,
"Status" : "Active",
"StatusCode" : "Y",
...
}
},
{
"id" : "part2",
"path" : "/procurementAgents/20000000000613",
"operation" : "update",
"payload" : {
"AssignmentId" : 20000000000613,
"Agent" : "Johnson, John",
"AgentId" : 132,
"AgentEmail" : "john.johnson@example.com",
"ProcurementBU" : "Vision Operations",
"ProcurementBUId" : 100000010018224,
"Status" : "Inactive",
...
}
}
]
}
例: 複数の購買オーダー明細のクローズ
このリクエストでは、バッチ内の複数の購買オーダー明細がクローズされます:
curl \
http://servername:fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/ \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/vnd.oracle.adf.batch+json'
{
"parts":[
{
"id" : "part1",
"path" : "purchaseOrders/100000019476400/child/lines/702260/action/close",
"operation" : "invoke",
"payload" :{
{
"closeAction" : "closeForReceiving"
},
{
"closeReason" : "Close for receiving reason line 1"
}
}
},
{
"id" : "part2",
"path" : "purchaseOrders/100000019476400/child/lines/702261/action/close",
"operation" : "invoke",
"payload" :{
{
"closeAction" : "closeForReceiving"
},
{
"closeReason" : "Close for receiving reason line 2"
}
}
}
]
}
バッチ・プロセスは、タスクをより迅速かつ効率的に実行するのに役立ちます。