Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

View the extensive REST API available with Compliance for Confluence to script automation using another tool (e.g. Python)


Note Internally, Classification Levels are set by their Index, e.g. by default:

  • Highly Restricted = 0
  • Restricted = 1
  • Internal = 2
  • Public = 3

You must use these index values in the REST API.

Table of Contents
outlinetrue
stylenone

Classify a Page

Classify a certain page under a classification level.

URL/rest/server-classification/1.0/classify?pid=12345&lid=2
Query Parameters

PID = Page ID, the page that you would like to classify

LID = Level ID, the level ID, as described above.

Response

200 if Success

401/403 if Unauthorized

Search for pages by their classification level using the Confluence CQL Search REST API.

Search for Unclassified Pages

Search for unclassified pages - pages pending a classification.

URL

/rest/api/content/search?cql=
type%20%3D%20page%20
AND%20space%20in%20(TEST)%20
AND%20(content.property%5Bclassification%5D.name.index%20!%3D%200%20
AND%20content.property%5Bclassification%5D.name.index%20!%3D%201%20
AND%20content.property%5Bclassification%5D.name.index%20!%3D%202%20
AND%20content.property%5Bclassification%5D.name.index%20!%3D%203)
&limit=20&start=0&expand=space,history.lastUpdated,metadata.properties.classification,metadata.labels,space.icon

Query ParameterscqlSearch Query*e.g. type = page AND space IN (TEST) AND (content.property[classification].name.index != 0 OR content.property[classification].name.index != 1 OR content.property[classification].name.index != 2 OR content.property[classification].name.index != 3)
startPagination Start Ate.g. 0
limitResults Limite.g. 100
expandExpand Fieldse.g. space, history.lastUpdated, metadata.properties.classification, metadata.labels, space.icon
Response
Code Block
titleResponse Body
collapsetrue
{  
   "results":[  
      {  
         "id":"851970",
         "type":"page",
         "status":"current",
         "title":"Test Home",
         "space":{  
            "id":884737,
            "key":"TEST",
            "name":"Test",
            "icon":{  
               "path":"/images/logo/default-space-logo.svg",
               "width":48,
               "height":48,
               "isDefault":false
            },
            "type":"global",
            "_expandable":{  
               "metadata":"",
               "description":"",
               "homepage":"/rest/api/content/851970"
            },
            "_links":{  
               "self":"http://localhost:1990/confluence/rest/api/space/TEST",
               "webui":"/display/TEST"
            }
         },
         "history":{  
            "lastUpdated":{  
               "by":{  
                  "type":"known",
                  "username":"admin",
                  "userKey":"ff80808160e8c8810160e8d6a1210000",
                  "profilePicture":{  
                     "path":"/confluence/images/icons/profilepics/default.svg",
                     "width":48,
                     "height":48,
                     "isDefault":true
                  },
                  "displayName":"admin",
                  "_expandable":{  
                     "status":""
                  },
                  "_links":{  
                     "self":"http://localhost:1990/confluence/rest/experimental/user?key=ff80808160e8c8810160e8d6a1210000"
                  }
               },
               "when":"2019-03-15T09:08:46.032Z",
               "message":"",
               "number":1,
               "minorEdit":false,
               "hidden":false,
               "_expandable":{  
                  "content":"/rest/api/content/851970"
               },
               "_links":{  
                  "self":"http://localhost:1990/confluence/rest/experimental/content/851970/version/1"
               }
            },
            "latest":true,
            "createdBy":{  
               "type":"known",
               "username":"admin",
               "userKey":"ff80808160e8c8810160e8d6a1210000",
               "profilePicture":{  
                  "path":"/confluence/images/icons/profilepics/default.svg",
                  "width":48,
                  "height":48,
                  "isDefault":true
               },
               "displayName":"admin",
               "_expandable":{  
                  "status":""
               },
               "_links":{  
                  "self":"http://localhost:1990/confluence/rest/experimental/user?key=ff80808160e8c8810160e8d6a1210000"
               }
            },
            "createdDate":"2019-03-15T09:08:46.032Z",
            "_expandable":{  
               "previousVersion":"",
               "contributors":"",
               "nextVersion":""
            },
            "_links":{  
               "self":"http://localhost:1990/confluence/rest/api/content/851970/history"
            }
         },
         "metadata":{  
            "labels":{  
               "results":[  

               ],
               "start":0,
               "limit":200,
               "size":0,
               "_links":{  
                  "self":"http://localhost:1990/confluence/rest/api/content/851970/label"
               }
            },
            "properties":{  
               "classification":{  
                  "id":"851972",
                  "key":"classification",
                  "value":{  
                     "name":{  
                        "value":"Highly Restricted",
                        "search":"Highly Restricted",
                        "index":0
                     },
                     "icon":{  
                        "url":"/images/dark-red.png"
                     },
                     "tooltip":{  
                        "value":"This page was classified as Highly Restricted by admin on Fri Mar 15 09:20:06 GMT 2019."
                     },
                     "updated":"Fri Mar 15 09:20:06 GMT 2019"
                  },
                  "version":{  
                     "when":"2019-03-15T09:20:06.853Z",
                     "message":"",
                     "number":1,
                     "minorEdit":false,
                     "hidden":false
                  },
                  "_expandable":{  
                     "content":"/rest/api/content/851970"
                  },
                  "_links":{  
                     "self":"http://localhost:1990/confluence/rest/api/content/851970/property/classification"
                  }
               },
               "_expandable":{  
                  "classificationhistory":""
               },
               "_links":{  
                  "self":"http://localhost:1990/confluence/rest/api/content/851970/property"
               }
            },
            "_expandable":{  
               "currentuser":"",
               "frontend":"",
               "editorHtml":""
            }
         },
         "extensions":{  
            "position":"none"
         },
         "_expandable":{  
            "container":"/rest/api/space/TEST",
            "operations":"",
            "children":"/rest/api/content/851970/child",
            "restrictions":"/rest/api/content/851970/restriction/byOperation",
            "ancestors":"",
            "body":"",
            "version":"",
            "descendants":"/rest/api/content/851970/descendant"
         },
         "_links":{  
            "self":"http://localhost:1990/confluence/rest/api/content/851970",
            "webui":"/display/TEST/Test+Home",
            "edit":"/pages/resumedraft.action?draftId=851970",
            "tinyui":"/x/AgAN"
         }
      }
   ],
   "start":0,
   "limit":20,
   "size":1,
   "_links":{  
      "base":"http://localhost:1990/confluence",
      "context":"/confluence",
      "self":"http://localhost:1990/confluence/rest/api/content/search?expand=space,history.lastUpdated,metadata.properties.classification,metadata.labels,space.icon&cql=type%20%3D%20page%20AND%20space%20in%20(TEST)"
   }
}

*You must chain the OR commands up to the same amount of levels you have in your system (like a JQL Query)

Search for Classified Pages

URL

/rest/api/content/search
?cql=type%20%3D%20page%20AND%20space%20in%20(TEST)%20AND%20(content.property%5Bclassification%5D.name.index%20!%3D%200%20)
&limit=20&start=0&expand=space,history.lastUpdated,metadata.properties.classification,metadata.labels,space.icon

Query Parameters


cqlSearch Query*e.g. type = page AND space IN (TEST) AND (content.property[classification].name.index = 0
startPagination Start Ate.g. 0
limitResults Limite.g. 100
expandExpand Fieldse.g. space, history.lastUpdated, metadata.properties.classification, metadata.labels, space.icon
Response
Code Block
titleResponse Body
collapsetrue
{  
   "results":[  
      {  
         "id":"851970",
         "type":"page",
         "status":"current",
         "title":"Test Home",
         "space":{  
            "id":884737,
            "key":"TEST",
            "name":"Test",
            "icon":{  
               "path":"/images/logo/default-space-logo.svg",
               "width":48,
               "height":48,
               "isDefault":false
            },
            "type":"global",
            "_expandable":{  
               "metadata":"",
               "description":"",
               "homepage":"/rest/api/content/851970"
            },
            "_links":{  
               "self":"http://localhost:1990/confluence/rest/api/space/TEST",
               "webui":"/display/TEST"
            }
         },
         "history":{  
            "lastUpdated":{  
               "by":{  
                  "type":"known",
                  "username":"admin",
                  "userKey":"ff80808160e8c8810160e8d6a1210000",
                  "profilePicture":{  
                     "path":"/confluence/images/icons/profilepics/default.svg",
                     "width":48,
                     "height":48,
                     "isDefault":true
                  },
                  "displayName":"admin",
                  "_expandable":{  
                     "status":""
                  },
                  "_links":{  
                     "self":"http://localhost:1990/confluence/rest/experimental/user?key=ff80808160e8c8810160e8d6a1210000"
                  }
               },
               "when":"2019-03-15T09:08:46.032Z",
               "message":"",
               "number":1,
               "minorEdit":false,
               "hidden":false,
               "_expandable":{  
                  "content":"/rest/api/content/851970"
               },
               "_links":{  
                  "self":"http://localhost:1990/confluence/rest/experimental/content/851970/version/1"
               }
            },
            "latest":true,
            "createdBy":{  
               "type":"known",
               "username":"admin",
               "userKey":"ff80808160e8c8810160e8d6a1210000",
               "profilePicture":{  
                  "path":"/confluence/images/icons/profilepics/default.svg",
                  "width":48,
                  "height":48,
                  "isDefault":true
               },
               "displayName":"admin",
               "_expandable":{  
                  "status":""
               },
               "_links":{  
                  "self":"http://localhost:1990/confluence/rest/experimental/user?key=ff80808160e8c8810160e8d6a1210000"
               }
            },
            "createdDate":"2019-03-15T09:08:46.032Z",
            "_expandable":{  
               "previousVersion":"",
               "contributors":"",
               "nextVersion":""
            },
            "_links":{  
               "self":"http://localhost:1990/confluence/rest/api/content/851970/history"
            }
         },
         "metadata":{  
            "labels":{  
               "results":[  

               ],
               "start":0,
               "limit":200,
               "size":0,
               "_links":{  
                  "self":"http://localhost:1990/confluence/rest/api/content/851970/label"
               }
            },
            "properties":{  
               "classification":{  
                  "id":"851972",
                  "key":"classification",
                  "value":{  
                     "name":{  
                        "value":"Highly Restricted",
                        "search":"Highly Restricted",
                        "index":0
                     },
                     "icon":{  
                        "url":"/images/dark-red.png"
                     },
                     "tooltip":{  
                        "value":"This page was classified as Highly Restricted by admin on Fri Mar 15 09:20:06 GMT 2019."
                     },
                     "updated":"Fri Mar 15 09:20:06 GMT 2019"
                  },
                  "version":{  
                     "when":"2019-03-15T09:20:06.853Z",
                     "message":"",
                     "number":1,
                     "minorEdit":false,
                     "hidden":false
                  },
                  "_expandable":{  
                     "content":"/rest/api/content/851970"
                  },
                  "_links":{  
                     "self":"http://localhost:1990/confluence/rest/api/content/851970/property/classification"
                  }
               },
               "_expandable":{  
                  "classificationhistory":""
               },
               "_links":{  
                  "self":"http://localhost:1990/confluence/rest/api/content/851970/property"
               }
            },
            "_expandable":{  
               "currentuser":"",
               "frontend":"",
               "editorHtml":""
            }
         },
         "extensions":{  
            "position":"none"
         },
         "_expandable":{  
            "container":"/rest/api/space/TEST",
            "operations":"",
            "children":"/rest/api/content/851970/child",
            "restrictions":"/rest/api/content/851970/restriction/byOperation",
            "ancestors":"",
            "body":"",
            "version":"",
            "descendants":"/rest/api/content/851970/descendant"
         },
         "_links":{  
            "self":"http://localhost:1990/confluence/rest/api/content/851970",
            "webui":"/display/TEST/Test+Home",
            "edit":"/pages/resumedraft.action?draftId=851970",
            "tinyui":"/x/AgAN"
         }
      }
   ],
   "start":0,
   "limit":20,
   "size":1,
   "_links":{  
      "base":"http://localhost:1990/confluence",
      "context":"/confluence",
      "self":"http://localhost:1990/confluence/rest/api/content/search?expand=space,history.lastUpdated,metadata.properties.classification,metadata.labels,space.icon&cql=type%20%3D%20page%20AND%20space%20in%20(TEST)"
   }
}

Settings

Get Classification Levels

Retrieve the classification levels for the system:

URL/rest/server-classification/1.0/levels
Response
Code Block
titleResponse Body
collapsetrue
{  
   "levels":[  
      {  
         "name":"Highly Restricted",
         "description":"Information presents the greatest danger if it were lost or disclosed. Only very limited audiences (sometimes just a single person) have access to this information.",
         "colour":"dark-red"
      },
      {  
         "name":"Restricted",
         "description":"Only people with a need to know should see Restricted information. Its loss or disclosure would pose a moderate to major risk.",
         "colour":"orange"
      },
      {  
         "name":"Internal",
         "description":"Commonly available to all employees. Internal information would pose only a minor risk if the information was lost or disclosed.",
         "colour":"blue"
      },
      {  
         "name":"Public",
         "description":"Lowest level of security, data is freely available to the public and employees. Public information requires no special protection.",
         "colour":"green"
      }
   ]
}

Get Space Settings

Get the Space Settings for a particular Space.

URL/rest/api/space/TEST/property/dataclassification (where TEST is the Space Key)
Response
Code Block
collapsetrue
{  
   "key":"dataclassification",
   "value":{  
      "enabled":true,
      "restricted":true,
      "force":false,
      "levelRestrictions":[  
         {  
            "name":"Highly Restricted",
            "users":[ ],
            "groups":[  
               "confluence-users"
            ]
         },
         {  
            "name":"Restricted",
            "users":[ ],
            "groups":[ ]
         },
         {  
            "name":"Internal",
            "users":[ ],
            "groups":[ ]
         },
         {  
            "name":"Public",
            "users":[ ],
            "groups":[ ]
         }
      ]
   },
   "version":{  
      "when":"2019-03-15T10:31:58.372Z",
      "message":"",
      "number":5,
      "minorEdit":false,
      "hidden":false
   },
   "_expandable":{  
      "space":"/rest/api/space/TEST"
   },
   "_links":{  
      "base":"http://localhost:1990/confluence",
      "context":"/confluence"
   }
}