# Resources ## Resource API: `/api/bw/v2/resource` API BW version 2 (Beta) Allows you to add, update, clone or delete Resources in a Boldest platform account. Among many other things, it can also be used to categorize Resources and assign them to existing Maps. ## Methods ### POST: Create/Update Resource - POST `json` Data to import in JSON format according to Schema /api/bw/v2/resource/schema.json Consult the [**`Schema documentation`**](#resource-schema-documentation) for the structure of the JSON data. **RESULT**: `HTTP 200` Skipped. The Resource exists and does not need to be updated ```json { "done": "Skip Resource TEST111", "id": "TEST111", "new": false, "update": false } ``` `HTTP 201` Created. The Resource did not exist, so it was created ```json { "done": "Create Resource TEST111", "id": "TEST111", "new": true, "update": true } ``` `HTTP 202` Accepted. The Resource existed, so it was updated ```json { "done": "Update Resource TEST111", "id": "TEST111", "new": false, "update": true } ``` `HTTP 400` Wrong request ```json { "fail": "Wrong request" } ``` `HTTP 401` Unauthorized ```json { "fail": "Unauthorized" } ``` `HTTP 409` Conflict. The submitted contents are not valid ```json { "fail": "Explanation of the problems encountered" } ``` ### GET: Get Resource/s - `/{ids}` Id or Ids CSV format (Optional) - `/mapId/{mapId}` Only Resources in Map mapId (Optional) (Default:All) - `/published/{1|0|*}` Published (Optional) (Default:1) - `/fields/{fields}` Only these fields (Optional) (Default:All) - `/ignoreFields/{fields}` Ignore these fields (Optional) (Default:None) - `/excludeFiles` Ignore file fields (Optional) (Default:No) **RESULT**: `HTTP 200` Success Resource data in JSON format according to Schema (schema.json or schema.multiple.json) `HTTP 400` Wrong request ```json { "fail": "Wrong request" } ``` `HTTP 401` Unauthorized ```json { "fail": "Unauthorized" } ``` `HTTP 404` Not found ```json { "fail": "ERROR: Export fail" } ``` ``` ### DELETE: Delete Resource/s - `/{ids}` Id or Ids CSV format **RESULT**: `HTTP 202` Deleted ```json { "done": "Deletion of 5 Resources done", "count": 5 // Number of Resources deleted } ``` Partial deletion ```json { "done": "Deletion of 3 Resources done", "count": 3, // Number of Resources deleted "fail": "Deletion of 2 Resources not done", "failed": ["TEST114", "TEST115"] } ``` `HTTP 400` Wrong request ```json { "fail": "Wrong request" } ``` `HTTP 401` Unauthorized ```json { "fail": "Unauthorized" } ``` `HTTP 404` Not found ```json { "fail": "No Resources to delete" } ``` `HTTP 409` Conflict. The submitted contents are not valid ```json { "fail": "Deletion of 5 Resources not done" } ``` ### POST: Request the Create/Update of a Resource group in a batch process - `/batch` Command - POST `json` Batch data to import in JSON format according to Schema (schema.multiple.json) **RESULT**: `HTTP 201` Created. The Resource did not exist, it is created ```json { "done": "Batch process created", "batchId": "22123112345678", "count": 123 // Number of Resources to be processed } ``` `HTTP 400` Wrong request ```json { "fail": "Wrong request" } ``` `HTTP 401` Unauthorized ```json { "fail": "Unauthorized" } ``` `HTTP 409` Conflict. The submitted contents are not valid ```json { "fail": "Explanation of the problems encountered" } ``` ### GET: Query the status of a batch process - `/batch` Command - `/{id}` Batch process Id **RESULT** `HTTP 200` Success ```json { "done": "Batch process status", "status": "waiting", // "waiting", "processing", "done", "error" "dateStatus": "2022-12-31 12:34:56", "dateRequest": "2022-12-31 12:34:56", "count": 123 } ``` `HTTP 400` Wrong request ```json { "fail": "Wrong request" } ``` `HTTP 401` Unauthorized ```json { "fail": "Unauthorized" } ``` `HTTP 404` Error ```json { "fail": "There is no Resource TEST111 to clone" } ``` ### POST/GET: Clone a Resource. Optionally can be added to a Map - `/clone` Command - `/{id}` Id (Optional) (Default: Resource "Base" is cloned) - `/map/{id}` Id of Map to be added to (Optional) **RESULT**: `HTTP 201` Cloned ```json { "done": "Cloned Resource TEST111 to Resource TEST111_8PtTXiU6mcw", "id": "TEST111_8PtTXiU6mcw" } ``` `HTTP 400` Wrong request ```json { "fail": "Wrong request" } ``` `HTTP 401` Unauthorized ```json { "fail": "Unauthorized" } ``` `HTTP 404` Error ```json { "fail": "There is no Resource TEST111 to clone" } ``` `HTTP 409` Fail ```json { "fail": "Not cloned Resource TEST111" } ``` ### GET: Get Schema JSON from the data structure of a Resource - `/full` Schema and data (Optinal) - `/schema.json` JSON schema for import **RESULT**: `HTTP 200` Success JSON schema document ### GET: Get Schema JSON schema of a group of Resources in a batch process - `/full` Schema and data (Optinal) - `/schema.multiple.json` Schema for batch import JSON **RESULT**: `HTTP 200` Success JSON schema document (resource-schema-documentation)= ```{include} resource.schema.json.md.merge :parser: myst_parser.sphinx_