docspan 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docspan/__init__.py +3 -0
- docspan/__main__.py +0 -0
- docspan/backends/__init__.py +19 -0
- docspan/backends/base.py +85 -0
- docspan/backends/confluence/__init__.py +0 -0
- docspan/backends/confluence/adf/__init__.py +14 -0
- docspan/backends/confluence/adf/comparator.py +427 -0
- docspan/backends/confluence/adf/converter.py +119 -0
- docspan/backends/confluence/adf/converters.py +1449 -0
- docspan/backends/confluence/adf/interfaces.py +191 -0
- docspan/backends/confluence/adf/nodes.py +2085 -0
- docspan/backends/confluence/adf/parser.py +400 -0
- docspan/backends/confluence/adf/validators.py +161 -0
- docspan/backends/confluence/adf/visitors.py +495 -0
- docspan/backends/confluence/backend.py +227 -0
- docspan/backends/confluence/client.py +44 -0
- docspan/backends/confluence/config/__init__.py +21 -0
- docspan/backends/confluence/config/loader.py +107 -0
- docspan/backends/confluence/config/models.py +167 -0
- docspan/backends/confluence/config/validation.py +297 -0
- docspan/backends/confluence/markdown/__init__.py +22 -0
- docspan/backends/confluence/markdown/ast.py +819 -0
- docspan/backends/confluence/markdown/extensions/__init__.py +5 -0
- docspan/backends/confluence/markdown/extensions/frontmatter.py +80 -0
- docspan/backends/confluence/markdown/extensions/mermaid.py +64 -0
- docspan/backends/confluence/markdown/extensions/wikilinks.py +179 -0
- docspan/backends/confluence/markdown/inline_parser.py +495 -0
- docspan/backends/confluence/markdown/parser.py +1006 -0
- docspan/backends/confluence/models/__init__.py +18 -0
- docspan/backends/confluence/models/markdown_file.py +402 -0
- docspan/backends/confluence/models/page.py +212 -0
- docspan/backends/confluence/models/path_utils.py +34 -0
- docspan/backends/confluence/models/results.py +28 -0
- docspan/backends/confluence/models/sync_status.py +382 -0
- docspan/backends/confluence/services/__init__.py +0 -0
- docspan/backends/confluence/services/confluence/__init__.py +40 -0
- docspan/backends/confluence/services/confluence/attachment_client.py +147 -0
- docspan/backends/confluence/services/confluence/base_client.py +420 -0
- docspan/backends/confluence/services/confluence/client.py +376 -0
- docspan/backends/confluence/services/confluence/comment_client.py +682 -0
- docspan/backends/confluence/services/confluence/crawler.py +587 -0
- docspan/backends/confluence/services/confluence/label_client.py +130 -0
- docspan/backends/confluence/services/confluence/page_client.py +1288 -0
- docspan/backends/confluence/services/confluence/space_client.py +179 -0
- docspan/backends/confluence/services/confluence/url_parser.py +106 -0
- docspan/backends/google_docs/__init__.py +0 -0
- docspan/backends/google_docs/auth.py +143 -0
- docspan/backends/google_docs/backend.py +140 -0
- docspan/backends/google_docs/client.py +665 -0
- docspan/backends/google_docs/converter.py +471 -0
- docspan/backends/google_docs/docs_request_builder.py +232 -0
- docspan/backends/google_docs/docs_structure_parser.py +120 -0
- docspan/backends/google_docs/markdown_to_paragraph_parser.py +145 -0
- docspan/cli/__init__.py +0 -0
- docspan/cli/main.py +408 -0
- docspan/config.py +62 -0
- docspan/core/__init__.py +49 -0
- docspan/core/merge.py +30 -0
- docspan/core/orchestrator.py +332 -0
- docspan/core/paths.py +8 -0
- docspan/core/state.py +53 -0
- docspan-0.1.0.dist-info/METADATA +273 -0
- docspan-0.1.0.dist-info/RECORD +65 -0
- docspan-0.1.0.dist-info/WHEEL +4 -0
- docspan-0.1.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Client for managing Confluence labels.
|
|
3
|
+
|
|
4
|
+
This module provides specialized functionality for working with Confluence labels,
|
|
5
|
+
including adding, retrieving, and removing labels.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Any, Dict, List
|
|
9
|
+
|
|
10
|
+
from docspan.backends.confluence.config.models import ConfluenceConfig
|
|
11
|
+
from docspan.backends.confluence.services.confluence.base_client import BaseConfluenceClient
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class LabelClient(BaseConfluenceClient):
|
|
15
|
+
"""
|
|
16
|
+
Client for managing Confluence labels.
|
|
17
|
+
|
|
18
|
+
Provides methods for adding, retrieving, and removing labels.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, config: ConfluenceConfig):
|
|
22
|
+
"""
|
|
23
|
+
Initialize the label client.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
config: Confluence configuration
|
|
27
|
+
"""
|
|
28
|
+
super().__init__(config)
|
|
29
|
+
|
|
30
|
+
def add_label(self, content_id: str, label: str) -> Dict[str, Any]:
|
|
31
|
+
"""
|
|
32
|
+
Add a label to a content item (page, blog post, etc.).
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
content_id: Content ID
|
|
36
|
+
label: Label to add
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Created label data
|
|
40
|
+
"""
|
|
41
|
+
endpoint = f"content/{content_id}/label"
|
|
42
|
+
|
|
43
|
+
data = {
|
|
44
|
+
"name": label,
|
|
45
|
+
"prefix": "global"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
self.logger.debug(f"Adding label '{label}' to content {content_id}")
|
|
49
|
+
return self._make_request(
|
|
50
|
+
method="POST",
|
|
51
|
+
endpoint=endpoint,
|
|
52
|
+
json_data=[data] # The API expects an array of label objects
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def add_labels(self, content_id: str, labels: List[str]) -> List[Dict[str, Any]]:
|
|
56
|
+
"""
|
|
57
|
+
Add multiple labels to a content item (page, blog post, etc.).
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
content_id: Content ID
|
|
61
|
+
labels: Labels to add
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
List of created label data
|
|
65
|
+
"""
|
|
66
|
+
if not labels:
|
|
67
|
+
return []
|
|
68
|
+
|
|
69
|
+
endpoint = f"content/{content_id}/label"
|
|
70
|
+
|
|
71
|
+
data = [{"name": label, "prefix": "global"} for label in labels]
|
|
72
|
+
|
|
73
|
+
self.logger.debug(f"Adding {len(labels)} labels to content {content_id}")
|
|
74
|
+
return self._make_request(
|
|
75
|
+
method="POST",
|
|
76
|
+
endpoint=endpoint,
|
|
77
|
+
json_data=data
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
def get_labels(self, content_id: str) -> List[Dict[str, Any]]:
|
|
81
|
+
"""
|
|
82
|
+
Get all labels for a content item.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
content_id: Content ID
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
List of label data
|
|
89
|
+
"""
|
|
90
|
+
endpoint = f"content/{content_id}/label"
|
|
91
|
+
params = {"limit": 100} # Set a reasonable limit
|
|
92
|
+
|
|
93
|
+
response = self._make_request(
|
|
94
|
+
method="GET",
|
|
95
|
+
endpoint=endpoint,
|
|
96
|
+
params=params
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Return the results
|
|
100
|
+
if isinstance(response, dict):
|
|
101
|
+
return response.get("results", [])
|
|
102
|
+
|
|
103
|
+
return []
|
|
104
|
+
|
|
105
|
+
def delete_label(self, content_id: str, label: str) -> bool:
|
|
106
|
+
"""
|
|
107
|
+
Delete a label from a content item.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
content_id: Content ID
|
|
111
|
+
label: Label to delete
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
True if successful, False otherwise
|
|
115
|
+
"""
|
|
116
|
+
endpoint = f"content/{content_id}/label"
|
|
117
|
+
params = {"name": label}
|
|
118
|
+
|
|
119
|
+
self.logger.debug(f"Deleting label '{label}' from content {content_id}")
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
self._make_request(
|
|
123
|
+
method="DELETE",
|
|
124
|
+
endpoint=endpoint,
|
|
125
|
+
params=params
|
|
126
|
+
)
|
|
127
|
+
return True
|
|
128
|
+
except Exception as e:
|
|
129
|
+
self.logger.error(f"Error deleting label: {e}")
|
|
130
|
+
return False
|