forked from atlassian-api/atlassian-python-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
50 lines (40 loc) · 1.5 KB
/
__init__.py
File metadata and controls
50 lines (40 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# coding=utf-8
"""
Confluence API client package for Atlassian Python API.
This package provides both Cloud and Server implementations of the Confluence API.
"""
from urllib.parse import urlparse
from .cloud import Cloud as ConfluenceCloud
from .server import Server as ConfluenceServer
# Legacy import for backward compatibility
from .base import ConfluenceBase
# Legacy Confluence class for backward compatibility
class Confluence(ConfluenceBase):
"""Legacy Confluence class for backward compatibility."""
def __init__(self, url, *args, **kwargs):
# Detect which implementation to use
# Priority: explicit cloud= kwarg > URL-based heuristic
is_cloud = kwargs.get("cloud")
if is_cloud is None:
hostname = urlparse(url).hostname or ""
is_cloud = (
hostname == "atlassian.net"
or hostname.endswith(".atlassian.net")
or hostname == "jira.com"
or hostname.endswith(".jira.com")
or hostname == "api.atlassian.com"
or hostname.endswith(".api.atlassian.com")
)
if is_cloud:
impl = ConfluenceCloud(url, *args, **kwargs)
else:
impl = ConfluenceServer(url, *args, **kwargs)
self._impl = impl
def __getattr__(self, attr):
# Delegate all unknown attributes to the true client
return getattr(self._impl, attr)
__all__ = [
"ConfluenceCloud",
"ConfluenceServer",
"ConfluenceBase",
]