Using the Workspaces REST API

The workspaces REST API provides a flexible mechanism to automate creation, management and deletion of workspaces.

Note that some role names in the REST API are different to the Hub role names. That is, "Manager" in the Hub is "Deploy Admin" in the REST service, and "Author" in the Hub is "Policy Author" in the REST service.

Example GET All Workspaces

The GET request URL looks like:

/opa-hub/api/12.2.33/workspaces

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


{
    "items": [
        {
            "name": "Default Collection",
            "description": "The default collection",
            "lockChannels": false,
            "defaultChannels": [
                "interview"
            ],
            "users": [
                {
                    "userName": "admin",
                    "fullName": "Sam Brown",
                    "roles": [
                        "Deploy Admin",
                        "Policy Author"
                    ]
                },
                // ... more users ...
            ],
            "links": // ...
        },
        // ... more workspaces ...
    ],
    "links": // ...
}

Example GET Single Workspace

The GET request URL looks like:

/opa-hub/api/12.2.33/workspaces/Example

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


{
    "name": "Example",
    "description": "An example collection",
    "lockChannels": false,
    "defaultChannels": [
        "interview"
    ],
    "users": [
        {
            "userName": "apiuser",
            "fullName": "api tester",
            "roles": [
                "Deploy Admin",
                "Viewer",
                "Policy Author"
            ]
        },
        // ... more users ...
    ],
    "links": // ...
}

Example POST Single Workspace

The POST request URL looks like:

/opa-hub/api/12.2.33/workspaces

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


{
    "name": "New workspace",
    "description": "The new workspace",
    "lockChannels": false,
    "defaultChannels": [
        "interview"
    ],
    "users": [
        {
            "userName": "admin",
            "fullName": "Alona Ali",
            "roles": [
                "Deploy Admin",
                "Policy Author"
            ]
        },
        // ... more users ...
   ]
}

Example PATCH Workspace

The request URL looks like:

/opa-hub/api/12.2.33/workspaces/Example

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


{
    "name": "Example",
    "description": "An example collection",
    "lockChannels": false,
    "defaultChannels": [
        "interview"
    ],
    "users": [
        {
            "userName": "admin",
            "fullName": "Akira Sun",
            "roles": [
                "Deploy Admin",
                "Policy Author"
            ]
        },
        // ... more users ...
   ]
}

Example DELETE Workspace

The request URL looks like:

/opa-hub/api/12.2.33/workspaces/Example

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