Script Question

This page defines the Script Question resource.

Scripts Questions are intermediary resources that associate Questions with Scripts.

Note: When putting or creating Script Question resources, it is up to the server to validate or return errors when problems with sequence arises.

Sections

Endpoints and URL structures

OSDI does not specify specific endpoints and link structures for compliant systems to use. Rather, because OSDI is a HAL+JSON API, endpoints and structures are defined in the links section of each returned resource, starting with the API Entry Point link.

HAL’s link structure lets an API consumer move through API levels, resources, and collections by parsing and following links. While most systems will not change the value of their links often and obey RESTful design principles, the value of each link when that resource is retrieved is the only canonical value, and it can change at any time.

The link relation label for a Script Question resource is osdi:script_question for a single Script resource or osdi:script_questions for a collection of Script Question resources.

Back to top…

Fields

The field names for this resource, with standard names, punctuation and capitalization, and values where appropriate.

Note: As with the entire OSDI specification, the specific fields a compliant system implements will vary between each system, as will the fields each system requires when creating or updating resources, which fields are writeable, and the operations you are allowed to perform on each resource.

Common Fields

A set of common fields that appear on all resources is included first, for reference.

Name Type Description
identifiers strings[] A unique string array of identifiers in the format [system name]:[id]. See the general concepts document for more information about identifiers.
created_date datetime A read-only property representing the date and time the resource was created on the local system.
modified_date datetime A read-only property representing the date and time the resource was last modified on the local system.

Control Headers

An “osdi:control” JSON object may contain common OSDI control headers which can be used on an OSDI POST, PUT, PATCH, Helper or other function calls to modify server behavior. Read More

Name Type Description
return_response boolean Defaults to true, if specified as false, the operation does not need to return the resource representation in the response

Back to top…

Script Fields

Name Type Description
sequence int A sequence number for the Scipt Question. Defines the position of the linked question in a script.

Back to top…

The links associated with this resource, available in the links section of the resource. Links that are part of the OSDI spec are typically prefixed with the osdi: namespace to aid in curie matching and readability.

Note: As with the entire OSDI specification, the specific links a compliant system supplies will vary between each system. In addition, systems may choose to embed a linked resource directly in the response in addition to linking to it in the links section, using the standard _embedded syntax described in the general overview documentation.

Name Type Description
question Question* A link to the associated Question resources for this Script Question.

Back to top…

Back to top…

Scenarios

The scenarios below show some common Create, Read, Update, Delete (CRUD) operations that can be performed on this resource, as well as any resource-specific behaviors worth highlighting. The following examples are for informational purposes. The authoritative resource definitions are above in the Fields tables and should be followed in the event of a conflict with the examples.

Scenario: Retrieving a collection of Script Question resources (GET)

Script Question resources can be retrieved as a collection of script questions for a specific script. Calling the script questions endpoint will return a collection of all the script questions associated with the script accessible with your api key.

Request

GET https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions

Header:
OSDI-API-Token:[your api key here]

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate

{
    "total_pages": 10,
    "per_page": 25,
    "page": 1,
    "total_records": 250,
    "_links": {
        "next": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions?page=2"
        },
        "osdi:script_questions": [
            {
                "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions/ae0e-4cd3-9ed7-d0"
            },
            {
                "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions/be0e-4cd3-9ed7-d0"
            },
            // truncated for brevity
        ],
        "curies": [
            {
                "name": "osdi",
                "href": "https://osdi-sample-system.org/docs/v1/{rel}",
                "templated": true
            }
        ],
        "self": {
            "href": https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions
        }
    },
    "_embedded": {
        "osdi:scipt_questions": [
            {
                "identifiers": [
                    "osdi_sample_system:ae0e-4cd3-9ed7-d0",
                    "foreign_system:1"
                ],
                "origin_system": "OSDI Sample System",
                "created_date": "2014-03-20T21:04:31Z",
                "modified_date": "2014-03-20T21:04:31Z",
                "sequence": 1,
                "_links": {
                    "curies": [
                        {
                            "name": "osdi",
                            "href": "https://osdi-sample-system.org/docs/v1/{rel}",
                            "templated": true
                        }
                    ],
                    "self": {
                        "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions/ae0e-4cd3-9ed7-d0"
                    },
                    "osdi:question": {
                        "href": "http://osdi-sample-system.org/api/v1/questions/202004"
                    },
                    "osdi:script": {
                        "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3"
                    }
                },
                "_embedded": {
                    "osdi:question": {
                        "origin_system": "OSDISystem",
                        "name": "foobar",
                        "description": "What is your name?",
                        "title": "foobar",
                        "summary": "What is your name?",
                        "question_type": "SingleChoice",
                        "identifiers": [
                            "OSDISystem:202004"
                        ],
                        "_links": {
                            "self": {
                                "href": "http://osdi-sample-system.org/api/v1/questions/202004"
                            },
                            "curies": [
                                {
                                    "name": "osdi",
                                    "href": "http://osdi-sample-system.org/osdi#{rel}",
                                    "templated": true
                                }
                            ]
                        }
                    }
                }
            },
            {
                "identifiers": [
                    "osdi_sample_system:be0e-4cd3-9ed7-d0",
                    "foreign_system:2"
                ],
                "origin_system": "OSDI Sample System",
                "created_date": "2014-03-20T21:04:31Z",
                "modified_date": "2014-03-20T21:04:31Z",
                "sequence": 2,
                "_links": {
                    "curies": [
                        {
                            "name": "osdi",
                            "href": "https://osdi-sample-system.org/docs/v1/{rel}",
                            "templated": true
                        }
                    ],
                    "self": {
                        "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions/be0e-4cd3-9ed7-d0"
                    },
                    "osdi:question": {
                        "href": "http://osdi-sample-system.org/api/v1/questions/203079"
                    },
                    "osdi:script": {
                        "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3"
                    }
                },
                "_embedded": {
                    "osdi:question": {
                        "origin_system": "OSDISystem",
                        "name": "pbank",
                        "description": "Will you phone bank?",
                        "title": "pbank",
                        "summary": "Will you phone bank?",
                        "question_type": "SingleChoice",
                        "responses": [
                            {
                                "key": "856278",
                                "name": "Yes",
                                "title": "Yes"
                            },
                            {
                                "key": "856279",
                                "name": "No",
                                "title": "No"
                            }
                        ],
                        "identifiers": [
                            "OSDISystem:203079"
                        ],
                        "_links": {
                            "self": {
                              "href": "http://osdi-sample-system.org/api/v1/questions/203079"
                            },
                            "curies": [
                                {
                                    "name": "osdi",
                                    "href": "http://osdi-sample-system.org/osdi#{rel}",
                                    "templated": true
                                }
                            ]
                        }
                    }
               }
            },
            // truncated for brevity
        ]
    }
}

Back to top…

Scenario: Retrieving an individual Script Question resource (GET)

Calling an individual Script Question resource will return the resource directly, along with all associated fields, embedded Questions and appropriate links to additional information about the script question.

Request

GET https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions/ae0e-4cd3-9ed7-d0

Header:
OSDI-API-Token:[your api key here]

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate

{
    "identifiers": [
        "osdi_sample_system:ae0e-4cd3-9ed7-d0",
        "foreign_system:1"
    ],
    "origin_system": "OSDI Sample System",
    "created_date": "2014-03-20T21:04:31Z",
    "modified_date": "2014-03-20T21:04:31Z",
    "sequence": 1,
    "_links": {
        "curies": [
            {
                "name": "osdi",
                "href": "https://osdi-sample-system.org/docs/v1/{rel}",
                "templated": true
            }
        ],
        "self": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions/ae0e-4cd3-9ed7-d0"
        },
        "osdi:question": {
            "href": "http://osdi-sample-system.org/api/v1/questions/202004"
        },
        "osdi:script": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3"
        }
    },
    "_embedded": {
        "osdi:question": {
            "origin_system": "OSDISystem",
            "name": "foobar",
            "description": "What is your name?",
            "title": "foobar",
            "summary": "What is your name?",
            "question_type": "SingleChoice",
            "identifiers": [
                "OSDISystem:202004"
            ],
            "_links": {
                "self": {
                    "href": "http://osdi-sample-system.org/api/v1/questions/202004"
                },
                "curies": [
                    {
                        "name": "osdi",
                        "href": "http://osdi-sample-system.org/osdi#{rel}",
                        "templated": true
                    }
                ]
            }
        }
    }
}

Back to top…

Scenario: Add a script question to the script (POST)

Posting to the script questions collection endpoint will allow you to add a new question to an existing script.

Request

POST https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions

Header:
OSDI-API-Token:[your api key here]

{
    "sequence": 1,
    "_links" : {
        "osdi:question" : "http://osdi-sample-system.org/api/v1/questions/52472"
    }
}

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate
{
    "identifiers": [
        "osdi_sample_system:ae0e-4cd3-9ed7-d0"
    ],
    "origin_system": "OSDI Sample System",
    "created_date": "2014-03-20T21:04:31Z",
    "modified_date": "2014-03-20T21:04:31Z",
    "sequence": 1,
    "origin_system": "OSDISystem",
    "_links": {
        "curies": [
            {
                "name": "osdi",
                "href": "https://osdi-sample-system.org/docs/v1/{rel}",
                "templated": true
            }
        ],
        "self": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions/ae0e-4cd3-9ed7-d0"
        },
        "osdi:question": {
            "href": "http://osdi-sample-system.org/api/v1/questions/202004"
        },
        "osdi:script": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3"
        }
    },
    "_embedded": {
        "osdi:question": {
            "origin_system": "OSDISystem",
            "name": "foobar",
            "description": "What is your name?",
            "title": "foobar",
            "summary": "What is your name?",
            "question_type": "SingleChoice",
            "identifiers": [
                "OSDISystem:202004"
            ],
            "_links": {
                "self": {
                    "href": "http://osdi-sample-system.org/api/v1/questions/202004"
                },
                "curies": [
                    {
                        "name": "osdi",
                        "href": "http://osdi-sample-system.org/osdi#{rel}",
                        "templated": true
                    }
                ]
            }
        }
    }
}
    

Scenario: Update a script question for the script (PUT)

Calling a PUT request on a script question endpoint will allow you to update a script question for the script.

Request

POST https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions/ae0e-4cd3-9ed7-d0

Header:
OSDI-API-Token:[your api key here]

{
    "sequence": 2,
}

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate
{
    "identifiers": [
        "osdi_sample_system:ae0e-4cd3-9ed7-d0"
    ],
    "origin_system": "OSDI Sample System",
    "created_date": "2014-03-20T21:04:31Z",
    "modified_date": "2014-03-20T21:04:31Z",
    "sequence": 2,
    "origin_system": "OSDISystem",
    "_links": {
        "curies": [
            {
                "name": "osdi",
                "href": "https://osdi-sample-system.org/docs/v1/{rel}",
                "templated": true
            }
        ],
        "self": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3/script_questions/ae0e-4cd3-9ed7-d0"
        },
        "osdi:question": {
            "href": "http://osdi-sample-system.org/api/v1/questions/202004"
        },
        "osdi:script": {
            "href": "https://osdi-sample-system.org/api/v1/scripts/d91b4b2e-ae0e-4cd3-9ed7-d0ecb0bc3"
        }
    },
    "_embedded": {
        "osdi:question": {
            "origin_system": "OSDISystem",
            "name": "foobar",
            "description": "What is your name?",
            "title": "foobar",
            "summary": "What is your name?",
            "question_type": "SingleChoice",
            "identifiers": [
                "OSDISystem:202004"
            ],
            "_links": {
                "self": {
                    "href": "http://osdi-sample-system.org/api/v1/questions/202004"
                },
                "curies": [
                    {
                        "name": "osdi",
                        "href": "http://osdi-sample-system.org/osdi#{rel}",
                        "templated": true
                    }
                ]
            }
        }
    }
}

Back to top…

Scenario: Delete a script question from the script (DELETE)

You may delete a script question from the script by calling the DELETE command on the script question endpoint.

Request

DELETE https://osdi-sample-system.org/api/v1/scripts/d32fcdd6-7366-466d-a3b8-7e0d87c3cd8b/script_questions/ae0e-4cd3-9ed7-d0

Header:
OSDI-API-Token:[your api key here]

Response

200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate

{
    "notice": "Script Question was deleted from the script."
}

Back to top…