Using the OPA Deployments REST API

Format for GET

Example GET All Deployments

The GET request URL looks like:

/opa-hub/api/12.2.8/deployments

The response to a get all deployments request looks like the following:


{
    "items": [
        {
            "name": "Example",
            "description": "Description of Example Project",
            "compatibilityMode": "latest",
            "collections": [
                "Default Collection"
            ],
            "services": [
                "interview",
                "webservice"
            ],
            "serviceURLs": {
                "interview": "{server}/web-determinations/startsession/Example",
                "webservice": "{server}/determinations-server/display/Example"
            },
            "versions": {
                "links": // ...
            },
            "logs": {
                "links": // ...
            },
            "links": // ...
        },
        {
            "name": "Example 2",
            "description": "Description of Example Project 2",
            "compatibilityMode": "latest",
            "collections": [
                "Default Collection"
            ],
            "services": [
                "interview",
                "webservice"
            ],
            "serviceURLs": {
                "interview": "{server}/web-determinations/startsession/Example%202",
                "webservice": "{server}/determinations-server/display/Example%202"
            },
            "versions": {
                "links": // ...
            },
            "logs": {
                "links": // ...
            },
            "links": // ...
        },
        // ... more deployments ...
    ]
}

Example GET Single Deployment

The GET request URL looks like:

/opa-hub/api/12.2.8/deployments/Example

The response to a single deployment request looks like the following:


{
    "name": "Example",
    "description": "Description of Example Project",
    "compatibilityMode": "latest",
    "collections":
    [
        "Default Collection"
    ],
    "services":
    [
        "interview",
        "webservice"
    ],
    "serviceURLs":
    {
        "interview": "{server}/web-determinations/startsession/Example",
        "webservice": "{server}/determinations-server/display/Example"
    },
    "versions":
    {
        "links": // ...
    },
    "logs":
    {
        "links": // ...
    },
    "links": // ...
}

Example GET Single Deployment, expand versions

The GET request URL looks like:

/opa-hub/api/12.2.8/deployments/Example?expand=versions

The response looks like the following:


{
    "name": "Example",
    "description": "Description of Example Project",
    "compatibilityMode": "latest",
    "collections":
    [
        "Default"
    ],
    "services":
    [
        "interview",
        "webservice"
    ],
    "serviceURLs":
    {
        "interview": "{server}/web-determinations/startsession/Example",
        "webservice": "{server}/determinations-server/display/Example"
    },
    "versions":
    {
        "items":
        [
            {
                "description": "Ad hoc project 'Example'. Deploy again.",
                "versionNo": 5,
                "addedBy": "admin",
                "activeVersionFlag": false,
                "opaVersion": "12.2.8",
                "date": "2016-10-26T03:31:51Z",
                "snapshot":
                {
                    "links": // ...
                },
                "links": // ...
            },
            // more versions ...
        ],
        "links": // ...
    },
    "logs":
    {
        "links": // ...
    },
    "links": // ...
}

Example GET All Deployment Versions

The GET request URL looks like:

/opa-hub/api/12.2.8/deployments/Example/versions/5

The response looks like:


{
    "items": [
        {
            "description": "Ad hoc project 'Example'. Deploy again.",
            "versionNo": 5,
            "addedBy": "admin",
            "activeVersionFlag": false,
            "opaVersion": "12.2.8",
            "date": "2016-10-26T03:31:51Z",
            "snapshot": {
                "links": // ...
            },
            "links": // ...
        },
        {
            "description": "Ad hoc project 'Example'. ",
            "versionNo": 4,
            "addedBy": "admin",
            "activeVersionFlag": false,
            "opaVersion": "12.2.8",
            "date": "2016-10-25T00:29:25Z",
            "snapshot": {
                "links": // ...
            },
            "links": // ...
        },
        // ... more versions ...
    ],
    "links": // ...
}

Example GET Deployment Version

The GET request URL looks like:

/opa-hub/api/12.2.8/deployments/Example/versions/5

The response looks like:


{
    "description": "Ad hoc project 'Example'. Deploy again.",
    "versionNo": 5,
    "addedBy": "admin",
    "activeVersionFlag": false,
    "opaVersion": "12.2.8",
    "date": "2016-10-26T03:31:51Z",
    "snapshot": {
        "links": // ...
    },
    "links": // ...
}

Example GET Deployment Version, expand snapshot

The GET request URL looks like:

/opa-hub/api/12.2.8/deployments/Example/versions/5?expand=snapshot

The response looks like the following:


{
    "description": "Ad hoc project 'Example'. Deploy again.",
    "versionNo": 5,
    "addedBy": "admin",
    "activeVersionFlag": false,
    "opaVersion": "12.2.8",
    "date": "2016-10-26T03:31:51Z",
    "snapshot": {
        "base64": "...snapshot base-64 data...",
        "links": // ...
    },
    "links": // ...
}

Example GET Deployment Snapshot

The GET request URL looks like:

/opa-hub/api/12.2.8/deployments/Example/versions/5/snapshot

By default, the result is returned in JSON format. The response looks like the following:


{
    "base64": "...snapshot base-64 data...",
    "links": // ...
}

Example GET Deployment Snapshot as binary data

To get the result as a binary Zip file, send the GET request with the following HTTP request header:

Accept: application/zip

The result will be returned as a Zip file. The HTTP response headers will also include the following information:

  • Cache-Control
  • ETag
  • Last-Modified
  • Vary

These additional headers allow the content to be cached by the REST client, and allow for conditional GET or HEAD requests to check for content freshness.

Example GET All Deployment Logs

The GET request URL looks like:

/opa-hub/api/12.2.8/deployments/Example/logs

The response looks like the following:


{
    "items":
    [
        {
            "date": "2016-11-04T00:33:59Z",
            "description": "Ad hoc project 'Example'. ",
            "updatedBy": "admin",
            "services": [
                "interview",
                "webservice"
            ],
            "activeVersion": 1
        },
        {
            "date": "2016-10-31T01:42:41Z",
            "description": "Ad hoc project 'Example'. ",
            "updatedBy": "admin",
            "services": [
                "mobile"
            ],
            "activeVersion": 1
        },
        // ... more log entries ...
    ],
    "links": // ...
}

Format for POST

Example POST Single Deployment

The POST request URL looks like:

/opa-hub/api/12.2.8/deployments

The basic structure expected for the POST request for the deployment resource is as follows:


{
    "name": "Example",
    "description": "Description of Example Project",
    "compatibilityMode": "latest",
    "services":
    [
        "interview",
        "webservice",
        "mobile",
        "javaScriptSessions"
    ],
    "collections":
    [
        "Default Collection"
    ],
    "versions":
    {
        "items":
        [
            {
                "description": "The initial version",
                "activeVersionFlag": true,
                "snapshot":
                {
                    "base64": "...base64 value..."
                }
            }
        ]
    }
}

When creating a new deployment, the deployment information, along with at least one version and snapshot, must be provided in the initial POST data.

Example POST List of Deployments

The POST request URL looks like:

/opa-hub/api/12.2.8/deployments

The structure expected for the POST request for the deployment resource is as follows:


{
    "items":
    [
        {
            "name": "Example",
            "description": "Description of Example Project",
            "compatibilityMode": "latest",
            "services":
            [
                "interview",
                "webservice",
                "mobile"
            ],
            "collections":
            [
                "Default Collection"
            ],
            "versions":
            {
                "items":
                [
                    {
                        "description": "The initial version of Example Project",
                        "activeVersionFlag": true,
                        "snapshot":
                        {
                            "base64": "...base64 value..."
                        }
                    }
                ]
            }
        },
        {
            "name": "Example 2",
            "description": "Description of Example Project 2",
            "compatibilityMode": "latest",
            "services":
            [
                "webservice",
                "mobile",
                "javaScriptSessions"
            ],
            "collections":
            [
                "Default Collection",
            ],
            "versions":
            {
                "items":
                [
                    {
                        "description": "The initial version of Example 2",
                        "activeVersionFlag": true,
                        "snapshot":
                        {
                            "base64": "...base64 value..."
                        }
                    }
                ]
            }
        }
    ]
}

Example POST Single Deployment Version

The POST request URL looks like:

/opa-hub/api/12.2.8/deployments/Example/versions

The basic structure expected for the POST request for the deployment version resource is as follows:


{
    "description": "A new version of Example Project",
    "activeVersionFlag": true,
    "snapshot":
    {
        "base64": "...base64 value..."
    }
}

This creates a new version for an existing deployment, and activates the new version immediately.

Example POST List of Deployment Versions

The POST request URL looks like:

/opa-hub/api/12.2.8/deployments/Example/versions

The structure expected for the POST request for the deployment version resource is as follows:


{
    "items":
    [
        {
            "description": "A new version",
            "activeVersionFlag": false,
            "snapshot":
            {
                "base64": "...base64 value..."
            }
        },
        {
            "description": "A new active version",
            "activeVersionFlag": true,
            "snapshot":
            {
                "base64": "...base64 value..."
            }
        }
    ]
}

This creates two new versions for an existing deployment, the second of which is activated immediately.

Format for PATCH

Example PATCH Deployment

The request URL looks like:

/opa-hub/api/12.2.8/deployments/Example

The structure expected for a PATCH request for the deployment resource is as follows:


{
    "compatibilityMode": "current",
    "services":
    [
        "interview",
        "mobile"
    ],
    "collections":
    [
        "Default"
    ]
}

Update compatibility mode, services, and/or collections for a given deployment.

Example PATCH Deployment Version

The request URL looks like:

/opa-hub/api/12.2.8/deployments/Example/versions/1

The structure expected for a PATCH request for the deployment version resource is as follows:


{
    "activeVersionFlag": false
}

Activate or deactivate a deployment version for a given deployment.

Format for DELETE

Example DELETE Deployment

The request URL looks like:

/opa-hub/api/12.2.8/deployments/Example

The response is an HTTP 204 response, with no JSON data returned.

Example DELETE Deployment Version

The request URL looks like:

/opa-hub/api/12.2.8/deployments/Example/versions/1

The response is an HTTP 204 response, with no JSON data returned.