Add an item to the entity set with id `entityset_id`, or change the items judgement. To delete an item from the entity set, apply the judgement: `no_judgement`. --- post: summary: Add item to an entityset parameters: - description: The entityset id. in: pat
(entityset_id)
| 351 | |
| 352 | @blueprint.route("/api/2/entitysets/<entityset_id>/items", methods=["POST", "PUT"]) |
| 353 | def item_update(entityset_id): |
| 354 | """Add an item to the entity set with id `entityset_id`, or change |
| 355 | the items judgement. |
| 356 | |
| 357 | To delete an item from the entity set, apply the judgement: `no_judgement`. |
| 358 | --- |
| 359 | post: |
| 360 | summary: Add item to an entityset |
| 361 | parameters: |
| 362 | - description: The entityset id. |
| 363 | in: path |
| 364 | name: entityset_id |
| 365 | required: true |
| 366 | schema: |
| 367 | type: string |
| 368 | example: 3a0d91ece2dce88ad3259594c7b642485235a048 |
| 369 | requestBody: |
| 370 | content: |
| 371 | application/json: |
| 372 | schema: |
| 373 | $ref: '#/components/schemas/EntitySetItemUpdate' |
| 374 | responses: |
| 375 | '200': |
| 376 | content: |
| 377 | application/json: |
| 378 | schema: |
| 379 | $ref: '#/components/schemas/EntitySetItem' |
| 380 | description: OK |
| 381 | '204': |
| 382 | description: Item removed |
| 383 | tags: |
| 384 | - EntitySetItem |
| 385 | """ |
| 386 | entityset = get_entityset(entityset_id, request.authz.WRITE) |
| 387 | data = parse_request("EntitySetItemUpdate") |
| 388 | entity = data.pop("entity", {}) |
| 389 | entity_id = data.pop("entity_id", entity.get("id")) |
| 390 | entity = get_index_entity(entity_id, request.authz.READ) |
| 391 | collection = get_db_collection(entity["collection_id"]) |
| 392 | data["added_by_id"] = request.authz.id |
| 393 | data.pop("collection", None) |
| 394 | item = save_entityset_item(entityset, collection, entity_id, **data) |
| 395 | db.session.commit() |
| 396 | job_id = get_session_id() |
| 397 | queue_task( |
| 398 | collection, SETTINGS.STAGE_UPDATE_ENTITY, job_id=job_id, entity_id=entity_id |
| 399 | ) |
| 400 | if item is not None: |
| 401 | # The entityset is needed to check if the item is writeable in the serializer: |
| 402 | item = item.to_dict(entityset=entityset) |
| 403 | else: |
| 404 | item = { |
| 405 | "id": "$".join((entityset_id, entity_id)), |
| 406 | "entityset_id": entityset_id, |
| 407 | "entityset_collection_id": entityset.collection_id, |
| 408 | "entity_id": entity_id, |
| 409 | "collection_id": entity["collection_id"], |
| 410 | "judgement": Judgement.NO_JUDGEMENT, |
nothing calls this directly
no test coverage detected