Atlassian Confluence Server
Atlassian Confluence Server API.
Utilities · Atlassian Confluence Server
Details
| ID | Atlassian Confluence Server |
|---|---|
| Provider | Atlassian |
| Category | Utilities |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Supported Modules | Agentix XSIAM |
README
Atlassian Confluence Server API.
This integration was integrated and tested with version 6.1 of Atlassian Confluence Server.
Configure Atlassian Confluence Server in Cortex
| Parameter | Required |
|---|---|
| Server URL (e.g. http://1.2.3.4:8090) | True |
| Username | False |
| Password | False |
| Personal Access Token | False |
| Use system proxy settings | False |
| Trust any certificate (not secure) | False |
Commands
You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
confluence-create-space
Creates a new Confluence space.
Base Command
confluence-create-space
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Space name, for example: “Test Space”. | Required |
| description | A description for the space. | Required |
| key | Space key, which will be used as input when creating or updating child components from a space. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Confluence.Space.ID | String | Space ID. |
| Confluence.Space.Key | String | Space key. |
| Confluence.Space.Name | String | Space name. |
confluence-create-content
Creates Confluence content for a given space.
Base Command
confluence-create-content
Input
| Argument Name | Description | Required |
|---|---|---|
| title | Confluence page title. | Required |
| type | Confluence content type. Can be “page” or “blogpost”. Possible values are: page, blogpost. Default is page. | Required |
| space | Space key to add content to a specific space. | Required |
| body | Confluence page body to add. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Confluence.Content.ID | String | Page content ID. |
| Confluence.Content.Title | String | Content title. |
| Confluence.Content.Type | String | Content type. |
| Confluence.Content.Body | String | Content body. |
confluence-list-spaces
Returns a list of all Confluence spaces.
Base Command
confluence-list-spaces
Input
| Argument Name | Description | Required |
|---|---|---|
| limit | Maximum number of spaces to return. Default is 25. | Optional |
| type | Filter the returned list of spaces by type. Can be “global” or “personal”. Possible values are: global, personal. | Optional |
| status | Filter the returned list of spaces by status. Can be “current” or “archived”. Possible values are: current, archived. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Confluence.Space.ID | String | Space ID. |
| Confluence.Space.Key | String | Space key. |
| Confluence.Space.Name | String | Space name. |
confluence-get-content
Returns Confluence content by space key and title.
Base Command
confluence-get-content
Input
| Argument Name | Description | Required |
|---|---|---|
| key | Space key. | Required |
| title | Content title. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Confluence.Content.ID | String | Content ID. |
| Confluence.Content.Title | String | Content title. |
| Confluence.Content.Type | String | Content type. |
| Confluence.Content.Version | String | Content version. |
| Confluence.Content.Body | String | Content body. |
confluence-get-page-as-pdf
Returns Confluence Page as PDF by PageID.
Base Command
confluence-get-page-as-pdf
Input
| Argument Name | Description | Required |
|---|---|---|
| pageid | ID of the Page to download as PDF. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| File.Size | number | File size. |
| File.SHA1 | string | SHA1 hash of the file. |
| File.SHA256 | string | SHA256 hash of the file. |
| File.Name | string | The sample name. |
| File.SSDeep | string | SSDeep hash of the file. |
| File.EntryID | string | War Room entry ID of the file. |
| File.Info | string | Basic information of the file. |
| File.Type | string | File type, e.g., “PE”. |
| File.MD5 | string | MD5 hash of the file. |
| File.Extension | string | File extension. |
confluence-delete-content
Deletes Confluence content.
Base Command
confluence-delete-content
Input
| Argument Name | Description | Required |
|---|---|---|
| id | Content ID. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Confluence.Content.Result | String | Content delete result. |
| Confluence.Content.ID | String | Content ID deleted. |
confluence-update-content
Update (overwrite) the existing content of a Confluence page with new content.
Base Command
confluence-update-content
Input
| Argument Name | Description | Required |
|---|---|---|
| pageid | Page ID used to find and update the page. | Required |
| currentversion | The version number, extracted from a content search. The integration will increment by 1. | Required |
| title | Title of the page to update. | Required |
| type | Content type. Can be “page” or “blogpost”. Possible values are: page, blogpost. Default is page. | Required |
| space | Space key to update. | Required |
| body | Content body to replace (overwrite) existing content of a Confluence page. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Confluence.Content.ID | String | Content ID. |
| Confluence.Content.Title | String | Content title. |
| Confluence.Content.Type | String | Content type. |
| Confluence.Content.Body | String | Content body. |
confluence-search-content
Fetches a list of content using the Confluence Query Language (CQL). For more information about CQL syntax, see https://developer.atlassian.com/server/confluence/advanced-searching-using-cql/
Base Command
confluence-search-content
Input
| Argument Name | Description | Required |
|---|---|---|
| cql | A CQL query string to use to locate content, for example: “space = DEV order by created”. | Required |
| cqlcontext | The context in which to execute a CQL search. The context is the JSON serialized form of SearchContext. | Optional |
| expand | A CSV list of properties to expand on the content. Default is version. | Optional |
| start | The start point of the collection to return. | Optional |
| limit | Maximum number of items to return. This can be restricted by fixed system limits. Default is 25. Default is 25. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Confluence.Content.ID | String | Content ID. |
| Confluence.Content.Title | String | Content title. |
| Confluence.Content.Type | String | Content type. |
| Confluence.Content.Version | String | Content version. |
Configuration parameters
url— Server URL (e.g. http://1.2.3.4:8090) (required)credentials— Usernamepersonal_access_token—proxy— Use system proxy settingsunsecure— Trust any certificate (not secure)
Commands (8)
-
confluence-create-contentCreates Confluence content for a given space.
-
confluence-create-spaceCreates a new Confluence space.
-
confluence-delete-contentDeletes Confluence content.
-
confluence-get-contentReturns Confluence content by space key and title.
-
confluence-get-page-as-pdfReturns Confluence Page as PDF by PageID.
-
confluence-list-spacesReturns a list of all Confluence spaces.
-
confluence-search-contentFetches a list of content using the Confluence Query Language (CQL). For more information about CQL syntax, see https://developer.atlassian.com/server/confluence/advanced-searching-using-cql/
-
confluence-update-contentUpdate (overwrite) the existing content of a Confluence page with new content.
from pytest_mock import MockerFixture import demistomock as demisto from CommonServerPython import entryTypes def test_create_space_command(mocker): """ Given: Demisto args and params. When: Running create_space_command. Then: ensures the expected result is returned """ mocker.patch.object(demisto, "results") mocker.patch.object( demisto, "params", return_value={"url": "url", "credentials": {"identifier": "identifier", "password": "password"}} ) mocker.patch.object(demisto, "args", return_value={"description": "description", "key": "key", "name": "name"}) import Confluence mocker.patch.object(Confluence, "http_request", return_value={"id": "id", "key": "key", "name": "name"}) Confluence.create_space_command() assert "Space created successfully" in demisto.results.call_args_list[0][0][0].get("HumanReadable") def test_create_content_command(mocker): """ Given: Demisto args and params. When: Running create_content_command. Then: ensures the expected result is returned """ mocker.patch.object(demisto, "results") mocker.patch.object( demisto, "params", return_value={"url": "url", "credentials": {"identifier": "identifier", "password": "password"}} ) mocker.patch.object(demisto, "args", return_value={"type": "type", "title": "title", "space": "space", "body": "body"}) import Confluence mocker.patch.object(Confluence, "http_request", return_value={"id": "id", "title": "title", "space": "space", "body": "body"}) Confluence.create_content_command() assert "New Content" in demisto.results.call_args_list[0][0][0].get("HumanReadable") def test_get_content_command(mocker): """ Given: Demisto args and params. When: Running get_content_command. Then: ensures the expected result is returned """ mocker.patch.object(demisto, "results") mocker.patch.object( demisto, "params", return_value={"url": "url", "credentials": {"identifier": "identifier", "password": "password"}} ) mocker.patch.object(demisto, "args", return_value={"key": "key", "title": "title"}) import Confluence mocker.patch.object( Confluence, "http_request", return_value={ "results": [ { "id": "id", "title": "title", "type": "type", "version": {"number": "number"}, "body": {"view": {"value": "value"}}, } ] }, ) Confluence.get_content_command() assert "Content" in demisto.results.call_args_list[0][0][0].get("HumanReadable") def test_list_spaces_command(mocker): """ Given: Demisto args and params. When: Running get_host_status_command normally. Then: ensures the expected result is returned """ mocker.patch.object(demisto, "results") mocker.patch.object( demisto, "params", return_value={"url": "url", "credentials": {"identifier": "identifier", "password": "password"}} ) mocker.patch.object(demisto, "args", return_value={"status": "status", "type": "type"}) import Confluence mocker.patch.object( Confluence, "http_request", return_value={ "results": [ { "id": "id", "key": "key", "name": "name", } ] }, ) Confluence.list_spaces_command() assert "Spaces" in demisto.results.call_args_list[0][0][0].get("HumanReadable") def test_delete_content_command(mocker): """ Given: Demisto args and params. When: Running a delete_content_command. Then: ensures the expected result is returned """ mocker.patch.object(demisto, "results") mocker.patch.object( demisto, "params", return_value={"url": "url", "credentials": {"identifier": "identifier", "password": "password"}} ) mocker.patch.object(demisto, "args", return_value={"id": "id"}) import Confluence mocker.patch.object(Confluence, "http_request", return_value={"Results": "Successfully Deleted Content ID id", "ID": "id"}) Confluence.delete_content_command() assert "Content" in demisto.results.call_args_list[0][0][0].get("HumanReadable") def test_update_content_command(mocker): """ Given: Demisto args and params. When: Running a pdate_content_command. Then: ensures the expected result is returned """ mocker.patch.object(demisto, "results") mocker.patch.object( demisto, "params", return_value={"url": "url", "credentials": {"identifier": "identifier", "password": "password"}} ) mocker.patch.object( demisto, "args", return_value={ "pageid": "pageid", "title": "title", "space": "space", "body": "body", "type": "type", "currentversion": "1", }, ) import Confluence mocker.patch.object( Confluence, "http_request", return_value={ "results": [ { "id": "id", "key": "key", "name": "name", } ] }, ) Confluence.update_content_command() assert "Updated Content" in demisto.results.call_args_list[0][0][0].get("HumanReadable") def test_search_content_command(mocker): """ Given: Demisto args and params. When: Running a search_content_command normally. Then: ensures the expected result is returned """ mocker.patch.object(demisto, "results") mocker.patch.object( demisto, "params", return_value={"url": "url", "credentials": {"identifier": "identifier", "password": "password"}} ) mocker.patch.object( demisto, "args", return_value={"cql": "cql", "cqlcontext": "cqlcontext", "expand": "expand", "start": "start", "limit": "limit"}, ) import Confluence mocker.patch.object( Confluence, "http_request", return_value={"results": [{"id": "id", "title": "title", "type": "type", "version": {"number": "number"}}]}, ) Confluence.search_content_command() assert "Content Search" in demisto.results.call_args_list[0][0][0].get("HumanReadable") def test_get_page_as_pdf_command_success(mocker: MockerFixture): """ Given: A page ID is provided to download the page as PDF. When: The get_page_as_pdf_command function is called. Then: The function should return the PDF file as a file result with the correct filename. """ # Mock arguments mocker.patch.object( demisto, "params", return_value={"url": "url", "credentials": {"identifier": "identifier", "password": "password"}} ) mocker.patch.object(demisto, "args", return_value={"pageid": "12345"}) # Mock the get_pdf function to return sample PDF data mock_pdf_data = b"sample pdf data" mocker.patch("Confluence.get_pdf", return_value=mock_pdf_data) # Mock the demisto.results function results_mock = mocker.patch.object(demisto, "results") import Confluence # Call the function Confluence.get_page_as_pdf_command() # Assert the expected file result was returned results_mock.assert_called_once() file_result = results_mock.call_args[0][0] assert file_result["Type"] == entryTypes["file"] assert file_result["File"] == "Confluence_page_12345.pdf" assert file_result["FileID"] is not None def test_get_pdf_success(mocker): """ Given: A valid page_id is provided to the get_pdf function. When: The function calls http_request to fetch the PDF content. Then: The function should return the response content. """ # Mock the http_request function mocker.patch.object( demisto, "params", return_value={"url": "url", "credentials": {"identifier": "identifier", "password": "password"}} ) mock_response = b"mock pdf content" mock_http_request = mocker.patch("Confluence.http_request", return_value=mock_response) import Confluence # Call the function page_id = "12345" result = Confluence.get_pdf(page_id) # Assert the result and that http_request was called with the correct parameters assert result == mock_response mock_http_request.assert_called_once_with( "GET", Confluence.SERVER + "/spaces/flyingpdf/pdfpageexport.action", None, params={"pageId": page_id}, resp_type="content" )