megaplan-sdk 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.
- megaplan_sdk/__init__.py +67 -0
- megaplan_sdk/auth.py +185 -0
- megaplan_sdk/cache.py +192 -0
- megaplan_sdk/client.py +201 -0
- megaplan_sdk/constants.py +16 -0
- megaplan_sdk/exceptions.py +180 -0
- megaplan_sdk/helpers.py +108 -0
- megaplan_sdk/http_client.py +390 -0
- megaplan_sdk/logging_config.py +53 -0
- megaplan_sdk/models/__init__.py +22 -0
- megaplan_sdk/models/base.py +16 -0
- megaplan_sdk/models/comment.py +58 -0
- megaplan_sdk/models/common.py +107 -0
- megaplan_sdk/models/contractor.py +137 -0
- megaplan_sdk/models/deal.py +96 -0
- megaplan_sdk/models/department.py +40 -0
- megaplan_sdk/models/employee.py +117 -0
- megaplan_sdk/models/project.py +76 -0
- megaplan_sdk/models/task.py +75 -0
- megaplan_sdk/resources/__init__.py +15 -0
- megaplan_sdk/resources/auth.py +73 -0
- megaplan_sdk/resources/base.py +794 -0
- megaplan_sdk/resources/comments.py +148 -0
- megaplan_sdk/resources/contractors.py +173 -0
- megaplan_sdk/resources/deals.py +625 -0
- megaplan_sdk/resources/departments.py +70 -0
- megaplan_sdk/resources/employees.py +216 -0
- megaplan_sdk/resources/full_details.py +143 -0
- megaplan_sdk/resources/projects.py +854 -0
- megaplan_sdk/resources/tasks.py +932 -0
- megaplan_sdk/types.py +56 -0
- megaplan_sdk-0.1.0.dist-info/METADATA +1383 -0
- megaplan_sdk-0.1.0.dist-info/RECORD +36 -0
- megaplan_sdk-0.1.0.dist-info/WHEEL +5 -0
- megaplan_sdk-0.1.0.dist-info/licenses/LICENSE +21 -0
- megaplan_sdk-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Project models for Megaplan SDK."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
8
|
+
|
|
9
|
+
from megaplan_sdk.models.base import BaseEntity
|
|
10
|
+
from megaplan_sdk.models.common import DateTime, TimestampMixin
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ProjectFilter(BaseModel):
|
|
14
|
+
"""Project filter configuration.
|
|
15
|
+
|
|
16
|
+
Can be used as filter ID (integer) or filter configuration (dict).
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
id: int | None = None
|
|
20
|
+
config: dict[str, Any] | None = None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Project(TimestampMixin):
|
|
24
|
+
"""Project model.
|
|
25
|
+
|
|
26
|
+
Represents a project in Megaplan with all its properties.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
id: int
|
|
30
|
+
content_type: str = Field(alias="contentType", default="Project")
|
|
31
|
+
name: str | None = None
|
|
32
|
+
description: str | None = None
|
|
33
|
+
status: str | None = None
|
|
34
|
+
owner: BaseEntity | None = None
|
|
35
|
+
responsible: BaseEntity | None = None
|
|
36
|
+
deadline: str | DateTime | dict[str, Any] | None = None # Can be DateOnly, DateTime, or string
|
|
37
|
+
actual_finish: str | DateTime | None = Field(alias="actualFinish", default=None)
|
|
38
|
+
parent: BaseEntity | None = None
|
|
39
|
+
priority: str | None = None
|
|
40
|
+
tags: list[BaseEntity] | None = None
|
|
41
|
+
attaches: list[BaseEntity] | None = None
|
|
42
|
+
todos: list[BaseEntity] | None = None
|
|
43
|
+
|
|
44
|
+
model_config = ConfigDict(populate_by_name=True, extra="ignore")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ProjectFullDetails(BaseModel):
|
|
48
|
+
"""Full project details with all related entities.
|
|
49
|
+
|
|
50
|
+
Attributes:
|
|
51
|
+
project: Main project entity.
|
|
52
|
+
deals: List of associated deals (if requested).
|
|
53
|
+
issues: List of tasks/issues (if requested).
|
|
54
|
+
actual_issues: List of actual tasks/issues (if requested).
|
|
55
|
+
comments: List of comments (if requested).
|
|
56
|
+
history: Change history entries (if requested).
|
|
57
|
+
auditors: List of auditors (if requested).
|
|
58
|
+
executors: List of executors/co-performers (if requested).
|
|
59
|
+
milestones: List of milestones (if requested).
|
|
60
|
+
responsible_details: Full responsible employee details (if requested).
|
|
61
|
+
owner_details: Full owner employee details (if requested).
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
project: Project
|
|
65
|
+
deals: list[Any] | None = None
|
|
66
|
+
issues: list[Any] | None = None
|
|
67
|
+
actual_issues: list[Any] | None = None
|
|
68
|
+
comments: list[Any] | None = None
|
|
69
|
+
history: list[dict[str, Any]] | None = None
|
|
70
|
+
auditors: list[Any] | None = None
|
|
71
|
+
executors: list[Any] | None = None
|
|
72
|
+
milestones: list[Any] | None = None
|
|
73
|
+
responsible_details: Any | None = None
|
|
74
|
+
owner_details: Any | None = None
|
|
75
|
+
|
|
76
|
+
model_config = ConfigDict(populate_by_name=True, extra="ignore")
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Task models for Megaplan SDK."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
8
|
+
|
|
9
|
+
from megaplan_sdk.models.base import BaseEntity
|
|
10
|
+
from megaplan_sdk.models.common import DateTime, TimestampMixin
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TaskFilter(BaseModel):
|
|
14
|
+
"""Task filter configuration.
|
|
15
|
+
|
|
16
|
+
Can be used as filter ID (integer) or filter configuration (dict).
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
id: int | None = None
|
|
20
|
+
config: dict[str, Any] | None = None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Task(TimestampMixin):
|
|
24
|
+
"""Task model.
|
|
25
|
+
|
|
26
|
+
Represents a task in Megaplan with all its properties.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
id: int
|
|
30
|
+
content_type: str = Field(alias="contentType", default="Task")
|
|
31
|
+
name: str | None = None
|
|
32
|
+
description: str | None = None
|
|
33
|
+
status: str | None = None
|
|
34
|
+
responsible: BaseEntity | None = None
|
|
35
|
+
owner: BaseEntity | None = None
|
|
36
|
+
deadline: str | DateTime | dict[str, Any] | None = None # Can be DateOnly, DateTime, or string
|
|
37
|
+
actual_finish: str | DateTime | None = Field(alias="actualFinish", default=None)
|
|
38
|
+
parent: BaseEntity | None = None
|
|
39
|
+
project: BaseEntity | None = None
|
|
40
|
+
priority: str | None = None
|
|
41
|
+
tags: list[BaseEntity] | None = None
|
|
42
|
+
attaches: list[BaseEntity] | None = None
|
|
43
|
+
todos: list[BaseEntity] | None = None
|
|
44
|
+
|
|
45
|
+
model_config = ConfigDict(populate_by_name=True, extra="ignore")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class TaskFullDetails(BaseModel):
|
|
49
|
+
"""Full task details with all related entities.
|
|
50
|
+
|
|
51
|
+
Attributes:
|
|
52
|
+
task: Main task entity.
|
|
53
|
+
sub_tasks: List of subtasks (if requested).
|
|
54
|
+
actual_sub_tasks: List of actual subtasks (if requested).
|
|
55
|
+
comments: List of comments (if requested).
|
|
56
|
+
history: Change history entries (if requested).
|
|
57
|
+
auditors: List of auditors (if requested).
|
|
58
|
+
executors: List of executors/co-performers (if requested).
|
|
59
|
+
milestones: List of milestones (if requested).
|
|
60
|
+
responsible_details: Full responsible employee details (if requested).
|
|
61
|
+
owner_details: Full owner employee details (if requested).
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
task: Task
|
|
65
|
+
sub_tasks: list[Any] | None = None
|
|
66
|
+
actual_sub_tasks: list[Any] | None = None
|
|
67
|
+
comments: list[Any] | None = None
|
|
68
|
+
history: list[dict[str, Any]] | None = None
|
|
69
|
+
auditors: list[Any] | None = None
|
|
70
|
+
executors: list[Any] | None = None
|
|
71
|
+
milestones: list[Any] | None = None
|
|
72
|
+
responsible_details: Any | None = None
|
|
73
|
+
owner_details: Any | None = None
|
|
74
|
+
|
|
75
|
+
model_config = ConfigDict(populate_by_name=True, extra="ignore")
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Resources for Megaplan SDK."""
|
|
2
|
+
|
|
3
|
+
from megaplan_sdk.resources.auth import AuthResource
|
|
4
|
+
from megaplan_sdk.resources.base import BaseResource
|
|
5
|
+
from megaplan_sdk.resources.deals import DealsResource
|
|
6
|
+
from megaplan_sdk.resources.projects import ProjectsResource
|
|
7
|
+
from megaplan_sdk.resources.tasks import TasksResource
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"BaseResource",
|
|
11
|
+
"AuthResource",
|
|
12
|
+
"TasksResource",
|
|
13
|
+
"ProjectsResource",
|
|
14
|
+
"DealsResource",
|
|
15
|
+
]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Authentication resource for Megaplan API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from megaplan_sdk.auth import AuthManager
|
|
8
|
+
from megaplan_sdk.http_client import HTTPClient
|
|
9
|
+
from megaplan_sdk.resources.base import BaseResource
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from megaplan_sdk.cache import EntityCache
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AuthResource(BaseResource):
|
|
16
|
+
"""Resource for OAuth2 authentication."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, http_client: HTTPClient, cache: EntityCache | None = None) -> None:
|
|
19
|
+
"""Initialize auth resource.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
http_client: HTTP client for making requests.
|
|
23
|
+
cache: Optional entity cache.
|
|
24
|
+
"""
|
|
25
|
+
super().__init__(http_client, cache=cache)
|
|
26
|
+
self._auth_manager = AuthManager(http_client)
|
|
27
|
+
|
|
28
|
+
async def authenticate(self, username: str, password: str) -> str:
|
|
29
|
+
"""Authenticate with username and password.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
username: User email or username.
|
|
33
|
+
password: User password.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
Access token.
|
|
37
|
+
"""
|
|
38
|
+
return await self._auth_manager.authenticate(username, password)
|
|
39
|
+
|
|
40
|
+
async def refresh_token(self, refresh_token: str | None = None) -> str:
|
|
41
|
+
"""Refresh access token.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
refresh_token: Optional refresh token. Uses stored token if not provided.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
New access token.
|
|
48
|
+
"""
|
|
49
|
+
return await self._auth_manager.refresh(refresh_token)
|
|
50
|
+
|
|
51
|
+
async def ensure_authenticated(self, username: str, password: str) -> str:
|
|
52
|
+
"""Ensure we have a valid access token.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
username: Username for authentication.
|
|
56
|
+
password: Password for authentication.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
Valid access token.
|
|
60
|
+
"""
|
|
61
|
+
return await self._auth_manager.ensure_authenticated(username, password)
|
|
62
|
+
|
|
63
|
+
def get_access_token(self) -> str | None:
|
|
64
|
+
"""Get current access token.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
Access token or None if not authenticated.
|
|
68
|
+
"""
|
|
69
|
+
return self._auth_manager.get_access_token()
|
|
70
|
+
|
|
71
|
+
def clear_tokens(self) -> None:
|
|
72
|
+
"""Clear stored tokens."""
|
|
73
|
+
self._auth_manager.clear_tokens()
|