# Resources ## Resource API: `/api/bw/v2/resource` 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. --- ## Endpoints ### POST `/api/bw/v2/resource` - Create/Update Resource Create or update a Resource using JSON data according to Schema. **Request:** - `json` (POST body) - 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. **Response `HTTP 200`** - Skipped (no update needed): ```json { "done": "Skip Resource TEST111", "id": "TEST111", "new": false, "update": false } ``` **Response `HTTP 201`** - Created: ```json { "done": "Create Resource TEST111", "id": "TEST111", "new": true, "update": true } ``` **Response `HTTP 202`** - Accepted (updated): ```json { "done": "Update Resource TEST111", "id": "TEST111", "new": false, "update": true } ``` **Response `HTTP 400`** - Wrong request: ```json { "fail": "Wrong request" } ``` **Response `HTTP 401`** - Unauthorized: ```json { "fail": "Unauthorized" } ``` **Response `HTTP 409`** - Conflict (invalid contents): ```json { "fail": "Explanation of the problems encountered" } ``` --- ### GET `/api/bw/v2/resource/{ids}` - Get Resources Retrieve one or more Resources by ID. **Request:** - `/{ids}` (path) - Id or Ids in CSV format (Optional) - `/mapId/{mapId}` (path) - Only Resources in Map mapId (Optional) (Omit for all) - `/published/{1|0|*}` (path) - Published status (Optional) (Default: 1) - `/fields/{fields}` (path) - Only these fields (Optional) (Omit for all) - `/ignoreFields/{fields}` (path) - Ignore these fields (Optional) (Omit for none) - `/excludeFiles` (path) - Ignore file fields (Optional) (Omit for none) **Response `HTTP 200`** - Success: Resource data in JSON format according to Schema (`schema.json` or `schema.multiple.json`) **Response `HTTP 400`** - Wrong request: ```json { "fail": "Wrong request" } ``` **Response `HTTP 401`** - Unauthorized: ```json { "fail": "Unauthorized" } ``` **Response `HTTP 404`** - Not found: ```json { "fail": "ERROR: Export fail" } ``` --- ### DELETE `/api/bw/v2/resource/{ids}` - Delete Resources Delete one or more Resources by ID. **Request:** - `/{ids}` (path) - Id or Ids in CSV format **Response `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"] } ``` **Response `HTTP 400`** - Wrong request: ```json { "fail": "Wrong request" } ``` **Response `HTTP 401`** - Unauthorized: ```json { "fail": "Unauthorized" } ``` **Response `HTTP 404`** - Not found: ```json { "fail": "No Resources to delete" } ``` **Response `HTTP 409`** - Conflict: ```json { "fail": "Deletion of 5 Resources not done" } ``` --- ### POST `/api/bw/v2/resource/batch` - Batch Create/Update Request the Create/Update of a Resource group in a batch process. **Request:** - `json` (POST body) - Batch data to import in JSON format according to Schema (`schema.multiple.json`) **Response `HTTP 201`** - Created: ```json { "done": "Batch process created", "batchId": "22123112345678", "count": 123 // Number of Resources to be processed } ``` **Response `HTTP 400`** - Wrong request: ```json { "fail": "Wrong request" } ``` **Response `HTTP 401`** - Unauthorized: ```json { "fail": "Unauthorized" } ``` **Response `HTTP 409`** - Conflict (invalid contents): ```json { "fail": "Explanation of the problems encountered" } ``` --- ### GET `/api/bw/v2/resource/batch/{id}` - Batch Status Query the status of a batch process. **Request:** - `/{id}` (path) - Batch process Id **Response `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 } ``` **Response `HTTP 400`** - Wrong request: ```json { "fail": "Wrong request" } ``` **Response `HTTP 401`** - Unauthorized: ```json { "fail": "Unauthorized" } ``` **Response `HTTP 404`** - Not found: ```json { "fail": "There is no Resource TEST111 to clone" } ``` --- ### POST/GET `/api/bw/v2/resource/clone/{id}` - Clone Resource Clone a Resource. Optionally can be added to a Map. **Request:** - `/{id}` (path) - Id (Optional) (Default: Resource "Base" is cloned) - `/map/{id}` (path) - Id of Map to be added to (Optional) **Response `HTTP 201`** - Cloned: ```json { "done": "Cloned Resource TEST111 to Resource TEST111_8PtTXiU6mcw", "id": "TEST111_8PtTXiU6mcw" } ``` **Response `HTTP 400`** - Wrong request: ```json { "fail": "Wrong request" } ``` **Response `HTTP 401`** - Unauthorized: ```json { "fail": "Unauthorized" } ``` **Response `HTTP 404`** - Not found: ```json { "fail": "There is no Resource TEST111 to clone" } ``` **Response `HTTP 409`** - Conflict: ```json { "fail": "Not cloned Resource TEST111" } ``` --- ### GET `/api/bw/v2/resource/schema.json` - Get Schema Get JSON Schema from the data structure of a Resource. **Request:** - `/full` (path) - Schema and data (Optional) **Response `HTTP 200`** - Success: JSON schema document --- ### GET `/api/bw/v2/resource/schema.multiple.json` - Get Batch Schema Get JSON Schema of a group of Resources in a batch process. **Request:** - `/full` (path) - Schema and data (Optional) **Response `HTTP 200`** - Success: JSON schema document --- (resource-schema-documentation)= ```{include} resource.schema.json.md.merge :parser: myst_parser.sphinx_ ```