1. ジョブAPI

ジョブAPIに切り替える

日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

Entities APIまたはQuerying APIの代わりにJobs APIを使用するには、現在Entities API /api/entitiesを使用しているM.TargetおよびM.JobDescriptionエンティティの取得、作成、更新、削除の呼び出しをJobs API /api/jobsの呼び出しに置き換える必要があります。

メモ

このチュートリアルを完了してコードを更新したら、推奨される手順に従って ジョブを管理できます

次の例は、skipクエリ パラメーターとtakeクエリ パラメーターを使用したJobs APIの呼び出しを示しています。

GET /api/jobs/123/targets?skip=0&take=25&state=Pending

Jobs APIに切り替えるには、コードを更新する必要があります。このチュートリアルでは、次の方法について説明します。

  1. ジョブ ターゲットとジョブの説明エンティティの呼び出しを見つけて更新します。

  2. ジョブ・ターゲットまたはジョブ記述を作成する呼び出しを見つけて更新します。

  3. ジョブ ターゲット エンティティを作成する呼び出しを見つけて更新します。

  4. ジョブ ターゲットまたはジョブの説明を削除する呼び出しを見つけて更新します。

手記

Jobs APIからのレスポンスの構造は、Entities APIおよびQuerying APIからのレスポンスと同じです。

ジョブ・ターゲットまたはジョブ記述エンティティの呼び出しの検索および更新

Entities APIを使用してジョブ ターゲット エンティティを取得するAPI呼び出しを見つけるには、次の例に示すような呼び出しを検索します。

GET /api/entities/{TARGET_ID}

この呼び出しは、次の例のような応答を返します。

HTTP status code 200

{
    "id": 31388,
    "identifier": "dLQk3EjdT46PvqdVeqXFgw",
    "cultures": [
        "en-US"
    ],
    "properties": {
        "Target.Location": "10607",
        "Target.StartedOn": "2024-10-22T18:31:01.9773702Z",
        "Target.CompletedOn": "2024-10-22T18:31:27.4345384Z",
        "Target.StateDescription": "File processed",
        "Target.Data": {
            "type": "Web",
            "href": "http://www.stylelabs.com/product/annotation-templates/400/Annotation report - PDF template.zip"
        },
        "Target.Scope": null,
        "Target.Priority": null,
        "Target.RetryCount": null,
        "Target.State": {
            "identifier": "Completed",
            "labels": {
                "en-US": "Completed"
            }
        },
        "Target.Condition": {
            "identifier": "Success",
            "labels": {
                "en-US": "Success"
            }
        },
        "Target.Type": {
            "identifier": "Fetch",
            "labels": {
                "en-US": "Fetch job"
            }
        },
        "Target.StatusData": {
            "code": "FileProcessed"
        },
        "Target.PriorityLevel": null
    },
    "relations": {
        "JobToTarget": {
            "href": "https://localhost:8180/api/entities/31388/relations/JobToTarget"
        }
    },
    "created_by": {
        "href": "https://localhost:8180/api/entities/6",
        "title": "The user who created the entity"
    },
    "created_on": "2024-10-22T18:31:01.879725Z",
    "modified_by": {
        "href": "https://localhost:8180/api/entities/6",
        "title": "The user who last modified the entity"
    },
    "modified_on": "2024-10-22T18:31:27.4733914Z",
    "entitydefinition": {
        "href": "https://localhost:8180/api/entitydefinitions/M.Target",
        "title": "The entity definition for this entity"
    },
    "copy": {
        "href": "https://localhost:8180/api/entities/31388/copy",
        "title": "Copy this entity"
    },
    "permissions": {
        "href": "https://localhost:8180/api/entities/31388/permissions",
        "title": "The permissions on this entity"
    },
    "lifecycle": {
        "href": "https://localhost:8180/api/entities/31388/lifecycle",
        "title": "The lifecycle action for this entity."
    },
    "saved_selections": {
        "href": "https://localhost:8180/api/entities/31388/savedselections",
        "title": "The saved selections this entity belongs to"
    },
    "roles": {
        "href": "https://localhost:8180/api/entities/31388/roles",
        "title": "Roles for this entity"
    },
    "annotations": {
        "href": "https://localhost:8180/api/entities/31388/annotations",
        "title": "Annotations for this entity"
    },
    "is_root_taxonomy_item": false,
    "is_path_root": false,
    "inherits_security": true,
    "is_system_owned": false,
    "version": 3,
    "self": {
        "href": "https://localhost:8180/api/entities/31388"
    },
    "renditions": {}
}

これを次のように置き換えます。

GET /api/jobs/{jobId}/targets

この呼び出しは、次の例のような応答を返します。

HTTP status code 200

{
    "items": [
        {
            "id": 31388,
            "identifier": "dLQk3EjdT46PvqdVeqXFgw",
            "cultures": [
                "en-US"
            ],
            "properties": {
                "Target.Location": "10607",
                "Target.StartedOn": "2024-10-22T18:31:01.9773702Z",
                "Target.CompletedOn": "2024-10-22T18:31:27.4345384Z",
                "Target.StateDescription": "File processed",
                "Target.Data": {
                    "type": "Web",
                    "href": "http://www.stylelabs.com/product/annotation-templates/400/Annotation report - PDF template.zip"
                },
                "Target.Scope": null,
                "Target.Priority": null,
                "Target.RetryCount": null,
                "Target.State": {
                    "identifier": "Completed",
                    "labels": {
                        "en-US": "Completed"
                    }
                },
                "Target.Condition": {
                    "identifier": "Success",
                    "labels": {
                        "en-US": "Success"
                    }
                },
                "Target.Type": {
                    "identifier": "Fetch",
                    "labels": {
                        "en-US": "Fetch job"
                    }
                },
                "Target.StatusData": {
                    "code": "FileProcessed"
                },
                "Target.PriorityLevel": null
            },
            "relations": {
                "JobToTarget": {
                    "parent": {
                        "href": "https://localhost:8180/api/entities/31380"
                    },
                    "inherits_security": true,
                    "self": {
                        "href": "https://localhost:8180/api/entities/31388/relations/JobToTarget"
                    }
                }
            },
            "created_by": {
                "href": "https://localhost:8180/api/entities/6",
                "title": "The user who created the entity"
            },
            "created_on": "2024-10-22T18:31:01.879725Z",
            "modified_by": {
                "href": "https://localhost:8180/api/entities/6",
                "title": "The user who last modified the entity"
            },
            "modified_on": "2024-10-22T18:31:27.4733914Z",
            "entitydefinition": {
                "href": "https://localhost:8180/api/entitydefinitions/M.Target",
                "title": "The entity definition for this entity"
            },
            "copy": {
                "href": "https://localhost:8180/api/entities/31388/copy",
                "title": "Copy this entity"
            },
            "permissions": {
                "href": "https://localhost:8180/api/entities/31388/permissions",
                "title": "The permissions on this entity"
            },
            "lifecycle": {
                "href": "https://localhost:8180/api/entities/31388/lifecycle",
                "title": "The lifecycle action for this entity."
            },
            "saved_selections": {
                "href": "https://localhost:8180/api/entities/31388/savedselections",
                "title": "The saved selections this entity belongs to"
            },
            "roles": {
                "href": "https://localhost:8180/api/entities/31388/roles",
                "title": "Roles for this entity"
            },
            "annotations": {
                "href": "https://localhost:8180/api/entities/31388/annotations",
                "title": "Annotations for this entity"
            },
            "is_root_taxonomy_item": false,
            "is_path_root": false,
            "inherits_security": true,
            "is_system_owned": false,
            "version": 3,
            "self": {
                "href": "https://localhost:8180/api/entities/31388"
            },
            "renditions": {}
        }
    ],
    "total_items": 1,
    "returned_items": 1,
    "offset": 0,
    "self": {
        "href": "https://localhost:8180/api/jobs/31380/targets?skip=0&take=25",
        "title": "This collection"
    }
}

Entities APIを使用してジョブ記述エンティティを取得するAPI呼び出しを見つけるには、次の例に示すような呼び出しを検索します。

GET /api/entities/{JOB_DESCRIPTION_ID}

この呼び出しは、次の例のような応答を返します。

HTTP status code 200

{
    "id": 31382,
    "identifier": "2OjPPWkhQj-4tc2dUGlaog",
    "cultures": [
        "en-US"
    ],
    "properties": {
        "Job.Configuration": {
            "file_id": 0,
            "asset_id": 10607,
            "files": [
                {
                    "type": "Web",
                    "href": "http://www.stylelabs.com/product/annotation-templates/400/Annotation report - PDF template.zip"
                }
            ],
            "post_fetch": [],
            "process_only_post_fetch_tasks": false,
            "key": "local-df77b7f3dfd040f3bb11805218077a0e"
        },
        "Job.Data": {
            "qbtMDX_JSAmNzJcIaMJxFA": {
                "Id": 31391,
                "has_completed": true
            }
        }
    },
    "relations": {
        "JobToJobDescription": {
            "parent": {
                "href": "https://localhost:8180/api/entities/31380"
            },
            "inherits_security": true,
            "self": {
                "href": "https://localhost:8180/api/entities/31382/relations/JobToJobDescription"
            }
        }
    },
    "created_by": {
        "href": "https://localhost:8180/api/entities/6",
        "title": "The user who created the entity"
    },
    "created_on": "2024-10-22T18:30:37.442564Z",
    "modified_by": {
        "href": "https://localhost:8180/api/entities/6",
        "title": "The user who last modified the entity"
    },
    "modified_on": "2024-10-22T18:31:27.135262Z",
    "entitydefinition": {
        "href": "https://localhost:8180/api/entitydefinitions/M.JobDescription",
        "title": "The entity definition for this entity"
    },
    "copy": {
        "href": "https://localhost:8180/api/entities/31382/copy",
        "title": "Copy this entity"
    },
    "permissions": {
        "href": "https://localhost:8180/api/entities/31382/permissions",
        "title": "The permissions on this entity"
    },
    "lifecycle": {
        "href": "https://localhost:8180/api/entities/31382/lifecycle",
        "title": "The lifecycle action for this entity."
    },
    "saved_selections": {
        "href": "https://localhost:8180/api/entities/31382/savedselections",
        "title": "The saved selections this entity belongs to"
    },
    "roles": {
        "href": "https://localhost:8180/api/entities/31382/roles",
        "title": "Roles for this entity"
    },
    "annotations": {
        "href": "https://localhost:8180/api/entities/31382/annotations",
        "title": "Annotations for this entity"
    },
    "is_root_taxonomy_item": false,
    "is_path_root": false,
    "inherits_security": true,
    "is_system_owned": false,
    "version": 3,
    "self": {
        "href": "https://localhost:8180/api/entities/31382"
    },
    "renditions": {}
}

これを次のように置き換えます。

GET /api/jobs/{jobId}/description

この呼び出しは、次の例のような応答を返します。

HTTP status code 200

{
    "id": 31382,
    "identifier": "2OjPPWkhQj-4tc2dUGlaog",
    "cultures": [
        "en-US"
    ],
    "properties": {
        "Job.Configuration": {
            "file_id": 0,
            "asset_id": 10607,
            "files": [
                {
                    "type": "Web",
                    "href": "http://www.stylelabs.com/product/annotation-templates/400/Annotation report - PDF template.zip"
                }
            ],
            "post_fetch": [],
            "process_only_post_fetch_tasks": false,
            "key": "local-df77b7f3dfd040f3bb11805218077a0e"
        },
        "Job.Data": {
            "qbtMDX_JSAmNzJcIaMJxFA": {
                "Id": 31391,
                "has_completed": true
            }
        }
    },
    "relations": {
        "JobToJobDescription": {
            "parent": {
                "href": "https://localhost:8180/api/entities/31380"
            },
            "inherits_security": true,
            "self": {
                "href": "https://localhost:8180/api/entities/31382/relations/JobToJobDescription"
            }
        }
    },
    "created_by": {
        "href": "https://localhost:8180/api/entities/6",
        "title": "The user who created the entity"
    },
    "created_on": "2024-10-22T18:30:37.442564Z",
    "modified_by": {
        "href": "https://localhost:8180/api/entities/6",
        "title": "The user who last modified the entity"
    },
    "modified_on": "2024-10-22T18:31:27.135262Z",
    "entitydefinition": {
        "href": "https://localhost:8180/api/entitydefinitions/M.JobDescription",
        "title": "The entity definition for this entity"
    },
    "copy": {
        "href": "https://localhost:8180/api/entities/31382/copy",
        "title": "Copy this entity"
    },
    "permissions": {
        "href": "https://localhost:8180/api/entities/31382/permissions",
        "title": "The permissions on this entity"
    },
    "lifecycle": {
        "href": "https://localhost:8180/api/entities/31382/lifecycle",
        "title": "The lifecycle action for this entity."
    },
    "saved_selections": {
        "href": "https://localhost:8180/api/entities/31382/savedselections",
        "title": "The saved selections this entity belongs to"
    },
    "roles": {
        "href": "https://localhost:8180/api/entities/31382/roles",
        "title": "Roles for this entity"
    },
    "annotations": {
        "href": "https://localhost:8180/api/entities/31382/annotations",
        "title": "Annotations for this entity"
    },
    "is_root_taxonomy_item": false,
    "is_path_root": false,
    "inherits_security": true,
    "is_system_owned": false,
    "version": 3,
    "self": {
        "href": "https://localhost:8180/api/entities/31382"
    },
    "renditions": {}
}

ジョブ・ターゲットまたはジョブ記述エンティティを作成するコールの検索および更新

エンティティAPIを使用する呼び出しをジョブAPIを使用する呼び出しに置き換える場合は、古いAPI呼び出しで使用されていたリクエスト本文が新しいAPI呼び出しに正しくマッピングされていることを確認してください。新しいエンドポイントでは、次の要求本文が必要です。

  • EntityPostResourceターゲットの作成用。

  • JobDescriptionResource職務記述書の作成用。

次の例は、M.TargetM.JobDescriptionを操作するときにEntities APIの使用からJobs APIに切り替える方法を示しています。

ジョブ ターゲット エンティティの作成

次に、Entities APIを使用してジョブ ターゲット エンティティを作成する例を示します。

POST /api/entities
Content-Type: application/json

{
  "properties": {
    "Target.StateDescription": <description>,
    "Target.Location": <location>
  },
  "relations": {
    "JobToTarget": {
       "parent": {
          "href": "https://<host>/api/entities/{jobId}"
       }
    }
  }
}

次のようにJobs APIを使用してこれを置き換えます。

POST /api/jobs/{jobId}/targets
Content-Type: application/json

{
  "properties": {
    "Target.StateDescription": <description>,
    "Target.Location": <location>
  }
}

ジョブ記述エンティティの作成

次に、Entities APIを使用して職務記述エンティティを作成する例を示します。

POST /api/entities
Content-Type: application/json

{
  "properties": {
    "Job.Data": {
      ...
    }
  },
  "relations": {
    "JobToTarget": {
       "parent": {
          "href": "https://<host>/api/entities/{jobId}"
       }
    }
  }
}

これを次のようにJobs APIを使用して置き換えます。

PUT /api/jobs/{jobId}/description
Content-Type: application/json

{
  "properties": {
    "Job.Data": {
      ...
    }
  }
}

ジョブ目標またはジョブ記述書の更新

Entities APIを使用してジョブ ターゲットまたはジョブ記述エンティティを更新するコード内の呼び出しを特定したら、これらの呼び出しをJobs APIを使用するように変更します。

大事な

PUTオペレーションは、ジョブに関連付けられたターゲットまたは説明に対して完全な更新を実行します。リクエストに含まれていないプロパティまたはリレーションはnullに設定されます。

PATCH操作は、ジョブに関連付けられたターゲットまたは説明に対して部分的な更新を実行します。リクエストに含まれるプロパティとリレーションのみが更新されます。

古いAPI呼び出しで使用されていた要求本文が新しいAPI呼び出しに正しくマッピングされていることを確認します。新しいエンドポイントでは、次の要求本文が必要です。

  • EntityResourceターゲットの更新 (PUT) または部分的な更新 (PATCH) 用。

  • JobDescriptionResource更新 (PUT) と、ジョブ記述を部分的に更新 (PATCH) するためのEntityResource。

次に、Entities APIを使用してジョブターゲットエンティティを更新する呼び出しを示します。

PUT /api/entities/{id}
PUT /api/entities/identifier/{identifier}
Content-Type: application/json

{
  "properties": {
    "Target.StateDescription": <description>,
    "Target.Location": <location>
  },
  "relations": {
    "JobToTarget": {
       "parent": {
          "href": "https://<host>/api/entities/{jobId}"
       }
    }
  }
}

次に示すのは、Jobs APIを使用してジョブ ターゲット エンティティを更新する呼び出しです。

PUT   /api/jobs/{jobId}/targets/{targetId}
PATCH /api/jobs/{jobId}/targets/{targetId}
Content-Type: application/json

{
  "properties": {
    "Target.StateDescription": <description>,
    "Target.Location": <location>
  }
}

次に示すのは、Entities APIを使用してジョブ記述エンティティを更新する呼び出しです。

PUT /api/entities/{id}
PUT /api/entities/identifier/{identifier}
Content-Type: application/json

{
  "properties": {
    "Job.Data": {
      ...
    }
  },
  "relations": {
    "JobToTarget": {
       "parent": {
          "href": "https://<host>/api/entities/{jobId}"
       }
    }
  }
}

次に示すのは、Jobs APIを使用してジョブ記述エンティティを更新する呼び出しです。

PUT   /api/jobs/{jobId}/description
PATCH /api/jobs/{jobId}/description 
Content-Type: application/json

{
  "properties": {
    "Job.Data": {
      ...
    }
  }
}

ジョブ・ターゲットまたはジョブ記述を削除する呼び出しの検索と更新

Entities APIを使用してジョブ・ターゲットまたはジョブ記述を削除する呼び出しをコード内で特定したら、これらの呼び出しをJobs APIを使用するように更新します。

次に示すのは、Entities APIを使用してジョブ対象エンティティを削除する呼び出しです。

DELETE /api/entities/{ID}

このコールを次のように置き換えます。

DELETE /api/jobs/{jobId}/targets/{targetId}

以下は、ジョブ記述エンティティを削除するエンティティです。

DELETE /api/entities/{ID}

このコールを次のように置き換えます。

DELETE /api/jobs/{JOB_ID}/description
この記事を改善するための提案がある場合は、 お知らせください!