Library Components

Note: implied_attributes and component_questions fields will only be shown in the Beta.

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.
icon_slug No The slug of the component's icon. A list of icon choices can be found at the /api/v2/library/component-icons/ endpoint. By default this will be mui-hub.

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

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,
    "implied_attributes": [],
    "component_questions": [],
    "icon_slug": "mui-hub",
    "icon_url": "/static/components/icons/mui-hub.svg"
}

Update a Component

This endpoint updates a 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.
icon_slug No The slug of the component's icon. A list of icon choices can be found at the /api/v2/library/component-icons/ endpoint.

Note that tasks_implemented and tasks_introduced may not share any common Countermeasures, and that any built-in Library Component's icon cannot be updated.

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,
    "implied_attributes": [
        "CAT1",
        "CAT2"
    ],
    "component_questions": ["AQ1"],
    "icon_slug": "mui-cookie"
}
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,
    "implied_attributes": [
        "CAT1",
        "CAT2"
    ],
    "component_questions": ["AQ1"],
    "icon_slug": "mui-cookie",
    "icon_url": "/static/components/icons/mui-cookie.svg"
}

Get all 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.
hidden Filters components based on hidden value.
search Filter components by performing a textual search on title.

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",
            "type": "Custom",
            "is_custom": true,
            "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,
            "implied_attributes": [
                "AT1",
                "AT2",
                "AT3"
            ],
            "component_questions": ["AQ4"],
            "icon_slug": "mui-hub",
            "icon_url": "/static/components/icons/mui-hub.svg"
        },
        {
            "id": "CSC2",
            "type": "Custom",
            "is_custom": true,
            "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,
            "implied_attributes": [],
            "component_questions": ["AQ5"],
            "icon_slug": "mui-hub",
            "icon_url": "/static/components/icons/mui-hub.svg"
        }
    ]
}

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
implied_attributes implied_attributes is expanded

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

{
    "results": [
        {
            "id": "CSC3",
            "type": "Custom",
            "is_custom": true,
            "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",
                "text": "JavaScript",
                "is_active": true,
                "section_title": "Platform and Language",
                "subsection_text": "Language and Framework",
                "question_text": "Programming Language",
                "subquestion_text": null
            },
            "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,
            "implied_attributes": [
                {
                    "id": 1,
                    "item_id": "CAT1",
                    "name": "Cloud Providers - New Amazon Web Services (AWS) Content (Story-driven) - A1333"
                },
                {
                    "id": 2,
                    "item_id": "CAT2",
                    "name": "Session Management Configuration - Accesses session cookie in client side JavaScript - A66"
                }
            ],
            "component_questions": ["AQ1"],
            "icon_slug": "mui-hub",
            "icon_url": "/static/components/icons/mui-hub.svg"
        }
    ]
}

Get a specific 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",
    "type": "Custom",
    "is_custom": true,
    "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,
    "component_questions": ["AQ1"],
    "icon_slug": "mui-hub",
    "icon_url": "/static/components/icons/mui-hub.svg"
}

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
implied_attributes implied_attributes is expanded

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

{
    "id": "CSC3",
    "type": "Custom",
    "is_custom": true,
    "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",
        "text": "JavaScript",
        "is_active": true,
        "section_title": "Platform and Language",
        "subsection_text": "Language and Framework",
        "question_text": "Programming Language",
        "subquestion_text": null
    },
    "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,
    "implied_attributes": [
        {
            "id": 1,
            "item_id": "CAT1",
            "name": "Cloud Providers - New Amazon Web Services (AWS) Content (Story-driven) - A1333"
        },
        {
            "id": 2,
            "item_id": "CAT2",
            "name": "Session Management Configuration - Accesses session cookie in client side JavaScript - A66"
        }
    ],
    "component_questions": ["AQ1"],
    "icon_slug": "mui-hub",
    "icon_url": "/static/components/icons/mui-hub.svg"
}

results matching ""

    No results matching ""