Library Components

Create a Custom Component

This endpoint creates a Custom Component.

POST /api/v2/library/components/

Payload

Fields Required Description
title Yes The title of the component.
description No A description of the component.
answer_mapping No The ID of the answer you wish to have this component associated with.
tasks_implemented No A list of task item_id strings.
tasks_introduced No A list of task item_id strings.
hidden No If hidden is true, the component will be in a staging state and will not be active in your project. By default hidden will be set to true.

Note that tasks_implemented and tasks_introduced may not share any common tasks.

POST /api/v2/library/components/ HTTP/1.1
Accept: application/json
Authorization: Token "YOUR SDE ACCESS TOKEN"

{  
    "title": "My Component",
    "description": "A custom component",
    "answer_mapping": "A1",
    "tasks_implemented": ["T12", "T13"],
    "tasks_introduced": ["T7"]
}
HTTP/1.1 201 CREATED
Content-Type: application/json

{
    "id": "CSC1",
    "title": "My Component",
    "description": "A custom component",
    "created": "2022-03-04T15:43:51.615743-05:00",
    "updated": "2022-03-04T15:43:51.615612-05:00",
    "answer_mapping": "A1",
    "tasks_implemented": ["T12", "T13"],
    "tasks_introduced": ["T7"],
    "hidden": true
}

Update a Custom Component

This endpoint updates a Custom Component.

PATCH /api/v2/library/components/{component_id}/

Payload

Fields Required Description
title No The title of the component.
description No A description of the component.
answer_mapping No The ID of the answer you wish to have this component assosiated with.
tasks_implemented No A list of task item_id strings.
tasks_introduced No A list of task item_id strings.
hidden No If hidden is true, the component will be in a staging state and will not be active in your project. By default hidden will be set to true.

Note that tasks_implemented and tasks_introduced may not share any common tasks.

PATCH /api/v2/library/components/CSC1/ HTTP/1.1
Accept: application/json
Authorization: Token "YOUR SDE ACCESS TOKEN"

{  
    "title": "My Updated Component",
    "description": "A custom component!",
    "answer_mapping": "A2",
    "tasks_implemented": ["T12", "T13"],
    "tasks_introduced": ["T7"],
    "hidden": false
}
HTTP/1.1 200 OK
Content-Type: application/json

{
    "id": "CSC1",
    "title": "My Updated Component",
    "description": "A custom component!",
    "created": "2022-03-04T15:43:51.615743-05:00",
    "updated": "2022-03-04T15:43:51.615612-05:00",
    "answer_mapping": "A2",
    "tasks_implemented": ["T12", "T13"],
    "tasks_introduced": ["T7"],
    "hidden": false
}

Get all Custom Components

This endpoint retrieves a list of Components.

GET /api/v2/library/components/

Query Parameters

The following parameters may be used to filter the components in the response.

Parameter Description
ordering Sort components by the specified field. Prefix field name with minus to sort descending. Sortable fields: title, last_update_date_time, hidden.

GET /api/v2/library/components/ HTTP/1.1
Accept: application/json
Authorization: Token "YOUR SDE ACCESS TOKEN"
HTTP/1.1 200 OK
Content-Type: application/json

{
    "results": [
        {
            "id": "CSC1",
            "title": "My Component",
            "description": "A custom component",
            "created": "2022-03-04T15:43:51.615743-05:00",
            "updated": "2022-03-04T15:43:51.615612-05:00",
            "answer_mapping": "A1",
            "tasks_implemented": ["T12", "T13"],
            "tasks_introduced": ["T7"],
            "hidden": true
        },
        {
            "id": "CSC2",
            "title": "Another Component",
            "description": "Another custom component",
            "created": "2022-03-04T15:43:51.615743-05:00",
            "updated": "2022-03-04T15:43:51.615612-05:00",
            "answer_mapping": "A2",
            "tasks_implemented": ["T4"],
            "tasks_introduced": [],
            "hidden": false
        }
    ]
}

Expand Parameters

See the Expand Parameters section for more details.

Parameter Description
tasks tasks_introduced and tasks_implemented are expanded
answer_mapping answer_mapping is expanded

GET /api/v2/library/components/?expand=tasks
Accept: application/json
Authorization: Token: "YOUR SDE ACCESS TOKEN"
HTTP/1.1 200 OK
Content-Type: application/json

{
    "results": [
        {
            "id": "CSC3",
            "title": "component",
            "description": "here goes the description",
            "category": "",
            "created": "2022-03-04T15:43:51.615743-05:00",
            "updated": "2022-03-04T15:43:51.615612-05:00",
            "answer_mapping": {
                "id": "A3",
                "title": "JavaScript",
                "is_active": true
            },
            "tasks_implemented": [
                {
                    "id": "T12",
                    "title": "Mask User Passwords by Default",
                    "url": "http://localhost:3000/library/tasks/T12/",
                    "active": true
                },
                {
                    "id": "T13",
                    "title": "Change Automatically Generated Passwords",
                    "url": "http://localhost:3000/library/tasks/T13/",
                    "active": true
                }
            ],
            "tasks_introduced": [
                {
                    "id": "T7",
                    "title": "Salt and hash stored passwords",
                    "url": "http://localhost:3000/library/tasks/T7/",
                    "active": true
                }
            ],
            "hidden": false
        }
    ]
}

Get a specific Custom Component

This endpoint retrieves a specific Component.

GET /api/v2/library/components/{component_id}/

URL Parameters

Parameter Description
component_id The id of the Component to retrieve.
GET /api/v2/library/components/CSC1/ HTTP/1.1
Accept: application/json
Authorization: Token "YOUR SDE ACCESS TOKEN"
HTTP/1.1 200 OK
Content-Type: application/json

{
    "id": "CSC1",
    "title": "My Component",
    "description": "A custom component",
    "created": "2022-03-04T15:40:42.334625-05:00",
    "updated": "2022-03-04T15:40:42.334461-05:00",
    "answer_mapping": "A1",
    "tasks_implemented": ["T12", "T13"],
    "tasks_introduced": ["T7"],
    "hidden": true
}

Expand Parameters

See the Expand Parameters section for more details.

Parameter Description
tasks tasks_introduced and tasks_implemented are expanded
answer_mapping answer_mapping is expanded

GET /api/v2/library/components/CSC3/?expand=tasks
Accept: application/json
Authorization: Token: "YOUR SDE ACCESS TOKEN"
HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "CSC3",
  "title": "component",
  "description": "here goes the description",
  "category": "",
  "created": "2022-03-04T15:43:51.615743-05:00",
  "updated": "2022-03-04T15:43:51.615612-05:00",
  "answer_mapping": {
      "id": "A3",
      "title": "JavaScript",
      "is_active": true
  },
  "tasks_implemented": [
      {
          "id": "T12",
          "title": "Mask User Passwords by Default",
          "url": "http://localhost:3000/library/tasks/T12/",
          "active": true
      },
      {
          "id": "T13",
          "title": "Change Automatically Generated Passwords",
          "url": "http://localhost:3000/library/tasks/T13/",
          "active": true
      }
  ],
  "tasks_introduced": [
      {
          "id": "T7",
          "title": "Salt and hash stored passwords",
          "url": "http://localhost:3000/library/tasks/T7/",
          "active": true
      }
  ],
  "hidden": false
}

results matching ""

    No results matching ""