Description
Is your feature request related to a problem? Please describe.
Currently, only Confluence Cloud is supported by the Confluence connector. Therefore, integration with Confluence Server is not yet supported.
Describe the solution you'd like
To enable this integration, it is first necessary to modify some classes of the source code so that it is possible to integrate with both Confluence Cloud and Confluence Server.
The first modification would be to insert a "cloud" parameter in the "SimpleConfluenceConfig" class that would allow the choice between Confluence Cloud or Confluence Server, because as verified in the documentation, the authentications are different. Thus, this class would assume a source code, as shown below.
@dataclass
class SimpleConfluenceConfig(BaseConnectorConfig):
"""Connector config where:
user_email is the email to authenticate into Confluence Cloud,
api_token is the api token to authenticate into Confluence Cloud,
and url is the URL pointing to the Confluence Cloud instance.
Check https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/
for more info on the api_token.
"""
user_email: str
access_config: ConfluenceAccessConfig
url: str
max_num_of_spaces: int = 500
max_num_of_docs_from_each_space: int = 100
spaces: t.List[str] = field(default_factory=list)
cloud: bool = True
With this parameter included, it would be possible to instantiate the Confluence API object with the different connections in the "confluence" property of the ConfluenceSourceConnector class, as shown below.
@dataclass
class ConfluenceSourceConnector(SourceConnectorCleanupMixin, BaseSourceConnector):
"""Fetches body fields from all documents within all spaces in a Confluence Cloud instance."""
connector_config: SimpleConfluenceConfig
_confluence: t.Optional["Confluence"] = field(init=False, default=None)
@property
def confluence(self) -> "Confluence":
from atlassian import Confluence
if self._confluence is None:
if self.connector_config.cloud:
self._confluence = Confluence(
url=self.connector_config.url,
username=self.connector_config.user_email,
password=self.connector_config.access_config.api_token,
)
else:
self._confluence = Confluence(
url=self.connector_config.url,
token=self.connector_config.access_config.api_token,
)
return self._confluence
Describe alternatives you've considered
I'm open to other suggestion and I can contribute with this changes.
Additional context
This suggestion was already tested connecting a Confluence Server and it worked fine.