Skip to content

Commit 3ea9e56

Browse files
committed
Fix .gitignore downloads pattern and add downloads directories to Git tracking
- Changed downloads/ to /downloads/ in .gitignore to only ignore root-level downloads - Added python_alfresco_api/clients/core/downloads/ to Git tracking - Added python_alfresco_api/raw_clients/alfresco_core_client/core_client/api/downloads/ to Git tracking - Fixes gray directory issue in IDE and packaging problems
1 parent 95f9cb3 commit 3ea9e56

File tree

8 files changed

+939
-1
lines changed

8 files changed

+939
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ __pycache__/
1111
build/
1212
develop-eggs/
1313
dist/
14-
downloads/
14+
/downloads/
1515
eggs/
1616
.eggs/
1717
lib/
@@ -142,6 +142,7 @@ dmypy.json
142142
.cursormemory
143143
.cursor/
144144
*.cursormemory
145+
memory-bank/
145146

146147
# macOS
147148
.DS_Store
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
Downloads Operations Client - Level 3: Downloads-Specific Operations
3+
4+
This module provides downloads-specific operations within the Core API.
5+
Part of the three-tier V1.1 architecture with complete 4-pattern detailed functions.
6+
"""
7+
8+
from .downloads_client import DownloadsClient
9+
from . import models
10+
11+
__all__ = ['DownloadsClient', 'models']
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
"""
2+
Downloads Operations Client - Level 3: Downloads-Specific Operations
3+
4+
This module provides downloads-specific operations within the Core API.
5+
Part of the three-tier V1.1 architecture with complete 4-pattern detailed functions.
6+
7+
Each operation provides 4 variants:
8+
- operation(params) - basic sync with explicit parameters
9+
- operation_async(params) - basic async with explicit parameters
10+
- operation_detailed(params) - detailed sync with explicit parameters
11+
- operation_detailed_async(params) - detailed async with explicit parameters
12+
13+
Perfect for MCP servers and documentation generation.
14+
"""
15+
16+
import asyncio
17+
from typing import Optional, List, Union, Any
18+
from httpx import Response
19+
20+
# Import from Level 3 (operation-specific models)
21+
from .models import DownloadsResponse, DownloadsListResponse, CreateDownloadsRequest
22+
23+
# Import raw operations
24+
try:
25+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import (
26+
cancel_download as _cancel_download,
27+
create_download as _create_download,
28+
get_download as _get_download
29+
)
30+
RAW_OPERATIONS_AVAILABLE = True
31+
except ImportError:
32+
RAW_OPERATIONS_AVAILABLE = False
33+
34+
35+
class DownloadsClient:
36+
"""
37+
Downloads operations client with 4-pattern detailed functions.
38+
39+
Provides high-level methods for downloads management operations
40+
that are essential for MCP servers and downloads workflows.
41+
42+
Each operation has 4 variants for maximum flexibility:
43+
- Basic sync/async for simple use cases
44+
- Detailed sync/async for full HTTP response access
45+
"""
46+
47+
def __init__(self, client_factory):
48+
"""Initialize with client factory for raw client access."""
49+
self._client_factory = client_factory
50+
self._raw_client = None
51+
52+
# Store raw operation references
53+
if RAW_OPERATIONS_AVAILABLE:
54+
self._cancel_download = _cancel_download
55+
self._create_download = _create_download
56+
self._get_download = _get_download
57+
58+
def _get_raw_client(self):
59+
"""Get or create the raw client."""
60+
if self._raw_client is None:
61+
# Import the raw core client directly
62+
from ....raw_clients.alfresco_core_client.core_client.client import AuthenticatedClient
63+
64+
# Create the raw client with same auth setup
65+
self._raw_client = AuthenticatedClient(
66+
base_url=f"{self._client_factory.base_url}/alfresco/api/-default-/public/alfresco/versions/1",
67+
token=self._client_factory.auth.get_auth_token(),
68+
prefix=self._client_factory.auth.get_auth_prefix(),
69+
verify_ssl=self._client_factory.verify_ssl
70+
)
71+
return self._raw_client
72+
73+
def get_httpx_client(self):
74+
"""
75+
Get direct access to raw httpx client for advanced operations.
76+
77+
Perfect for MCP servers that need raw HTTP access.
78+
"""
79+
return self._get_raw_client().get_httpx_client()
80+
81+
# ==================== CANCEL_DOWNLOAD OPERATION ====================
82+
83+
def cancel_download(self, download_id: str) -> Any:
84+
"""Cancel Download operation."""
85+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import cancel_download
86+
return cancel_download.sync(client=self._get_raw_client(), download_id=download_id)
87+
88+
async def cancel_download_async(self, download_id: str) -> Any:
89+
"""Cancel Download operation (async)."""
90+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import cancel_download
91+
return await cancel_download.asyncio(client=self._get_raw_client(), download_id=download_id)
92+
93+
def cancel_download_detailed(self, download_id: str) -> Response:
94+
"""Cancel Download operation (detailed)."""
95+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import cancel_download
96+
return cancel_download.sync_detailed(client=self._get_raw_client(), download_id=download_id)
97+
98+
async def cancel_download_detailed_async(self, download_id: str) -> Response:
99+
"""Cancel Download operation (detailed, async)."""
100+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import cancel_download
101+
return await cancel_download.asyncio_detailed(client=self._get_raw_client(), download_id=download_id)
102+
103+
# ==================== CREATE_DOWNLOAD OPERATION ====================
104+
105+
def create_download(self, body: Any, fields: Optional[List[str]] = None) -> Any:
106+
"""Create Download operation."""
107+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import create_download
108+
from ....raw_clients.alfresco_core_client.core_client.types import UNSET
109+
return create_download.sync(
110+
client=self._get_raw_client(),
111+
body=body,
112+
fields=fields if fields is not None else UNSET
113+
)
114+
115+
async def create_download_async(self, body: Any, fields: Optional[List[str]] = None) -> Any:
116+
"""Create Download operation (async)."""
117+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import create_download
118+
from ....raw_clients.alfresco_core_client.core_client.types import UNSET
119+
return await create_download.asyncio(
120+
client=self._get_raw_client(),
121+
body=body,
122+
fields=fields if fields is not None else UNSET
123+
)
124+
125+
def create_download_detailed(self, body: Any, fields: Optional[List[str]] = None) -> Response:
126+
"""Create Download operation (detailed)."""
127+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import create_download
128+
from ....raw_clients.alfresco_core_client.core_client.types import UNSET
129+
return create_download.sync_detailed(
130+
client=self._get_raw_client(),
131+
body=body,
132+
fields=fields if fields is not None else UNSET
133+
)
134+
135+
async def create_download_detailed_async(self, body: Any, fields: Optional[List[str]] = None) -> Response:
136+
"""Create Download operation (detailed, async)."""
137+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import create_download
138+
from ....raw_clients.alfresco_core_client.core_client.types import UNSET
139+
return await create_download.asyncio_detailed(
140+
client=self._get_raw_client(),
141+
body=body,
142+
fields=fields if fields is not None else UNSET
143+
)
144+
145+
# ==================== GET_DOWNLOAD OPERATION ====================
146+
147+
def get_download(self, download_id: str, fields: Optional[List[str]] = None) -> Any:
148+
"""Get Download operation."""
149+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import get_download
150+
from ....raw_clients.alfresco_core_client.core_client.types import UNSET
151+
return get_download.sync(
152+
client=self._get_raw_client(),
153+
download_id=download_id,
154+
fields=fields if fields is not None else UNSET
155+
)
156+
157+
async def get_download_async(self, download_id: str, fields: Optional[List[str]] = None) -> Any:
158+
"""Get Download operation (async)."""
159+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import get_download
160+
from ....raw_clients.alfresco_core_client.core_client.types import UNSET
161+
return await get_download.asyncio(
162+
client=self._get_raw_client(),
163+
download_id=download_id,
164+
fields=fields if fields is not None else UNSET
165+
)
166+
167+
def get_download_detailed(self, download_id: str, fields: Optional[List[str]] = None) -> Response:
168+
"""Get Download operation (detailed)."""
169+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import get_download
170+
from ....raw_clients.alfresco_core_client.core_client.types import UNSET
171+
return get_download.sync_detailed(
172+
client=self._get_raw_client(),
173+
download_id=download_id,
174+
fields=fields if fields is not None else UNSET
175+
)
176+
177+
async def get_download_detailed_async(self, download_id: str, fields: Optional[List[str]] = None) -> Response:
178+
"""Get Download operation (detailed, async)."""
179+
from ....raw_clients.alfresco_core_client.core_client.api.downloads import get_download
180+
from ....raw_clients.alfresco_core_client.core_client.types import UNSET
181+
return await get_download.asyncio_detailed(
182+
client=self._get_raw_client(),
183+
download_id=download_id,
184+
fields=fields if fields is not None else UNSET
185+
)
186+
187+
def __repr__(self) -> str:
188+
"""String representation for debugging."""
189+
base_url = getattr(self._client_factory, 'base_url', 'unknown')
190+
return f"DownloadsClient(base_url='{base_url}')"
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
"""
2+
Level 3: Downloads Operation Models - Specific to Downloads Operations
3+
4+
This module contains models that are specific to downloads operations
5+
within the Core API.
6+
7+
Three-Tier Architecture:
8+
- Level 1: Global models shared across ALL APIs
9+
- Level 2: Core API models shared within Core API
10+
- Level 3 (This file): Downloads operation-specific models
11+
12+
Benefits:
13+
- Perfect locality (downloads models exactly where downloads operations are)
14+
- Clean imports (from .models import DownloadsResponse)
15+
- Logical organization (operation-specific grouping)
16+
"""
17+
18+
from typing import Optional, List, Dict, Any, Annotated
19+
from datetime import datetime
20+
from pydantic import BaseModel, Field, ConfigDict
21+
22+
# Import from Level 1 (global)
23+
from ...models import BaseEntry, ContentInfo, UserInfo
24+
25+
# Import from Level 2 (Core API)
26+
from ..models import CoreResponse
27+
28+
29+
class DownloadsResponse(CoreResponse):
30+
"""Response wrapper for downloads operations."""
31+
entry: BaseEntry = Field(..., description="Downloads data")
32+
33+
34+
class DownloadsListResponse(BaseModel):
35+
"""Response wrapper for downloads list operations."""
36+
model_config = ConfigDict(extra='forbid')
37+
38+
list: Dict[str, Any] = Field(..., description="List data with pagination")
39+
40+
41+
# Operation-specific models will be added here based on analysis
42+
# Example models for common patterns:
43+
44+
45+
class CreateDownloadsRequest(BaseModel):
46+
"""Request model for creating downloads."""
47+
model_config = ConfigDict(extra='forbid')
48+
49+
name: Annotated[str, Field(
50+
description="Downloads name",
51+
min_length=1,
52+
max_length=255
53+
)]
54+
55+
properties: Annotated[Optional[Dict[str, Any]], Field(
56+
description="Custom properties",
57+
default=None
58+
)]
59+
60+
61+
class UpdateDownloadsRequest(BaseModel):
62+
"""Request model for updating downloads."""
63+
model_config = ConfigDict(extra='forbid')
64+
65+
name: Annotated[Optional[str], Field(
66+
description="Updated name",
67+
min_length=1,
68+
max_length=255,
69+
default=None
70+
)]
71+
72+
properties: Annotated[Optional[Dict[str, Any]], Field(
73+
description="Updated properties",
74+
default=None
75+
)]
76+
77+
78+
# Export all models
79+
__all__ = [
80+
'DownloadsResponse',
81+
'DownloadsListResponse',
82+
'CreateDownloadsRequest',
83+
'UpdateDownloadsRequest'
84+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
""" Contains endpoint functions for accessing the API """

0 commit comments

Comments
 (0)