mc5-api-client 1.0.17__py3-none-any.whl → 1.0.19__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.
- mc5_api_client/__init__.py +195 -7
- mc5_api_client/client.py +92 -16
- mc5_api_client/easy_mc5.py +682 -0
- mc5_api_client/pc_storage_client.py +229 -0
- mc5_api_client/pc_storage_quick.py +234 -0
- mc5_api_client/platform.py +3 -4
- mc5_api_client/storage_admin.py +285 -0
- {mc5_api_client-1.0.17.dist-info → mc5_api_client-1.0.19.dist-info}/METADATA +165 -20
- {mc5_api_client-1.0.17.dist-info → mc5_api_client-1.0.19.dist-info}/RECORD +13 -9
- {mc5_api_client-1.0.17.dist-info → mc5_api_client-1.0.19.dist-info}/WHEEL +0 -0
- {mc5_api_client-1.0.17.dist-info → mc5_api_client-1.0.19.dist-info}/entry_points.txt +0 -0
- {mc5_api_client-1.0.17.dist-info → mc5_api_client-1.0.19.dist-info}/licenses/LICENSE +0 -0
- {mc5_api_client-1.0.17.dist-info → mc5_api_client-1.0.19.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# ────────────[ CHIZOBA ]────────────────────────────
|
|
2
|
+
# | Email : chizoba2026@hotmail.com
|
|
3
|
+
# | File : pc_storage_client.py
|
|
4
|
+
# | License : MIT License © 2026 Chizoba
|
|
5
|
+
# | Brief | PC storage admin client for MC5 API
|
|
6
|
+
# ────────────────★─────────────────────────────────
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
PC Storage Admin Client for MC5 API with storage, storage_restricted, and storage_admin scopes.
|
|
10
|
+
Provides advanced squad management capabilities for PC platform.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from typing import Optional, Dict, Any, List
|
|
14
|
+
from .client import MC5Client
|
|
15
|
+
from .platform import Platform
|
|
16
|
+
from .storage_admin import StorageAdminMixin
|
|
17
|
+
from .auth import TokenGenerator
|
|
18
|
+
from .exceptions import MC5APIError
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class PCStorageClient(MC5Client, StorageAdminMixin):
|
|
22
|
+
"""
|
|
23
|
+
PC Storage Admin Client with advanced squad management capabilities.
|
|
24
|
+
|
|
25
|
+
This client uses storage scopes to provide admin-level squad management
|
|
26
|
+
including deletion, comprehensive updates, and audit capabilities.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
username: Optional[str] = None,
|
|
32
|
+
password: Optional[str] = None,
|
|
33
|
+
device_id: Optional[str] = None,
|
|
34
|
+
scope: str = "alert auth chat leaderboard_ro lobby message session social config storage storage_restricted storage_admin tracking_bi feed storage leaderboard_admin social_eve social soc transaction schedule lottery voice matchmaker",
|
|
35
|
+
auto_refresh: bool = True,
|
|
36
|
+
timeout: int = 30
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
Initialize PC Storage Admin Client.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
username: MC5 username (default: game:mc5_system)
|
|
43
|
+
password: Account password (default: admin)
|
|
44
|
+
device_id: Device ID (generated if not provided)
|
|
45
|
+
scope: Permission scopes with storage capabilities
|
|
46
|
+
auto_refresh: Whether to auto-refresh tokens
|
|
47
|
+
timeout: Request timeout in seconds
|
|
48
|
+
debug_mode: Enable debug mode
|
|
49
|
+
"""
|
|
50
|
+
# Default to game:mc5_system for storage admin
|
|
51
|
+
if username is None:
|
|
52
|
+
username = "game:mc5_system"
|
|
53
|
+
if password is None:
|
|
54
|
+
password = "admin"
|
|
55
|
+
|
|
56
|
+
# Set storage-specific attributes before calling parent constructor
|
|
57
|
+
self._storage_scope = scope
|
|
58
|
+
self._device_id = device_id or ""
|
|
59
|
+
self._username = username
|
|
60
|
+
self._password = password
|
|
61
|
+
|
|
62
|
+
# Initialize with PC platform
|
|
63
|
+
super().__init__(
|
|
64
|
+
username=username,
|
|
65
|
+
password=password,
|
|
66
|
+
platform=Platform.PC,
|
|
67
|
+
client_id="1875:55979:6.0.0a:windows:windows",
|
|
68
|
+
auto_refresh=auto_refresh,
|
|
69
|
+
timeout=timeout
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Override token generation for storage admin
|
|
73
|
+
self.token_generator = TokenGenerator()
|
|
74
|
+
|
|
75
|
+
# Set storage base URL
|
|
76
|
+
self._storage_base_url = "https://eur-seshat.gameloft.com"
|
|
77
|
+
|
|
78
|
+
def authenticate(
|
|
79
|
+
self,
|
|
80
|
+
username: Optional[str] = None,
|
|
81
|
+
password: Optional[str] = None,
|
|
82
|
+
device_id: Optional[str] = None
|
|
83
|
+
) -> Dict[str, Any]:
|
|
84
|
+
"""
|
|
85
|
+
Authenticate with storage admin scopes.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
username: Username (uses instance default if None)
|
|
89
|
+
password: Password (uses instance default if None)
|
|
90
|
+
device_id: Device ID (uses instance default if None)
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
Authentication response with storage scopes
|
|
94
|
+
"""
|
|
95
|
+
username = username or self._username
|
|
96
|
+
password = password or self._password
|
|
97
|
+
device_id = device_id or self._device_id
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
token_data = self.token_generator.generate_token(
|
|
101
|
+
username=username,
|
|
102
|
+
password=password,
|
|
103
|
+
device_id=device_id,
|
|
104
|
+
scope=self._storage_scope
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
self._token_data = token_data
|
|
108
|
+
self._username = username
|
|
109
|
+
|
|
110
|
+
# Update session headers
|
|
111
|
+
self.session.headers.update({
|
|
112
|
+
"User-Agent": f"MC5-PC-Storage-Admin/1.0.17",
|
|
113
|
+
"Accept": "application/json",
|
|
114
|
+
"Content-Type": "application/json"
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
return token_data
|
|
118
|
+
|
|
119
|
+
except Exception as e:
|
|
120
|
+
raise MC5APIError(f"Storage admin authentication failed: {e}")
|
|
121
|
+
|
|
122
|
+
def get_storage_info(self) -> Dict[str, Any]:
|
|
123
|
+
"""
|
|
124
|
+
Get current storage admin information.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
Storage admin information including scopes and capabilities
|
|
128
|
+
"""
|
|
129
|
+
if not self._token_data:
|
|
130
|
+
return {"error": "Not authenticated"}
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
"username": self._username,
|
|
134
|
+
"platform": self.get_platform_info()["platform"],
|
|
135
|
+
"scopes": self._token_data.get("scopes", []),
|
|
136
|
+
"client_id": self.client_id,
|
|
137
|
+
"has_storage": "storage" in self._token_data.get("scopes", []),
|
|
138
|
+
"has_storage_restricted": "storage_restricted" in self._token_data.get("scopes", []),
|
|
139
|
+
"has_storage_admin": "storage_admin" in self._token_data.get("scopes", []),
|
|
140
|
+
"capabilities": self._get_storage_capabilities()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
def _get_storage_capabilities(self) -> List[str]:
|
|
144
|
+
"""Get available storage capabilities based on scopes."""
|
|
145
|
+
scopes = self._token_data.get("scopes", [])
|
|
146
|
+
capabilities = []
|
|
147
|
+
|
|
148
|
+
if "storage" in scopes:
|
|
149
|
+
capabilities.extend([
|
|
150
|
+
"read_squad_info",
|
|
151
|
+
"update_squad_info",
|
|
152
|
+
"get_all_squads",
|
|
153
|
+
"get_squad_audit_log"
|
|
154
|
+
])
|
|
155
|
+
|
|
156
|
+
if "storage_restricted" in scopes:
|
|
157
|
+
capabilities.extend([
|
|
158
|
+
"limited_squad_updates",
|
|
159
|
+
"read_squad_audit_log"
|
|
160
|
+
])
|
|
161
|
+
|
|
162
|
+
if "storage_admin" in scopes:
|
|
163
|
+
capabilities.extend([
|
|
164
|
+
"delete_squad",
|
|
165
|
+
"batch_delete_squads",
|
|
166
|
+
"transfer_squad_ownership",
|
|
167
|
+
"full_squad_management",
|
|
168
|
+
"admin_audit_access"
|
|
169
|
+
])
|
|
170
|
+
|
|
171
|
+
return capabilities
|
|
172
|
+
|
|
173
|
+
def quick_squad_management_report(self, squad_id: str) -> Dict[str, Any]:
|
|
174
|
+
"""
|
|
175
|
+
Generate a comprehensive squad management report.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
squad_id: Squad ID to analyze
|
|
179
|
+
|
|
180
|
+
Returns:
|
|
181
|
+
Comprehensive squad report
|
|
182
|
+
"""
|
|
183
|
+
try:
|
|
184
|
+
# Get squad info
|
|
185
|
+
squad_info = self.get_squad_storage_info(squad_id)
|
|
186
|
+
|
|
187
|
+
# Get audit log if available
|
|
188
|
+
audit_log = None
|
|
189
|
+
if self._has_storage_capability("get_squad_audit_log"):
|
|
190
|
+
try:
|
|
191
|
+
audit_log = self.get_squad_audit_log(squad_id, limit=10)
|
|
192
|
+
except:
|
|
193
|
+
audit_log = {"error": "Audit log not available"}
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
"squad_id": squad_id,
|
|
197
|
+
"squad_info": squad_info,
|
|
198
|
+
"audit_log": audit_log,
|
|
199
|
+
"storage_capabilities": self._get_storage_capabilities(),
|
|
200
|
+
"available_actions": self._get_available_actions(squad_id)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
except Exception as e:
|
|
204
|
+
return {"error": f"Failed to generate report: {e}"}
|
|
205
|
+
|
|
206
|
+
def _has_storage_capability(self, capability: str) -> bool:
|
|
207
|
+
"""Check if a specific storage capability is available."""
|
|
208
|
+
return capability in self._get_storage_capabilities()
|
|
209
|
+
|
|
210
|
+
def _get_available_actions(self, squad_id: str) -> List[str]:
|
|
211
|
+
"""Get available actions for a squad based on storage capabilities."""
|
|
212
|
+
actions = []
|
|
213
|
+
|
|
214
|
+
if self._has_storage_capability("read_squad_info"):
|
|
215
|
+
actions.append("read_info")
|
|
216
|
+
|
|
217
|
+
if self._has_storage_capability("update_squad_info"):
|
|
218
|
+
actions.append("update_info")
|
|
219
|
+
|
|
220
|
+
if self._has_storage_capability("delete_squad"):
|
|
221
|
+
actions.append("delete")
|
|
222
|
+
|
|
223
|
+
if self._has_storage_capability("transfer_squad_ownership"):
|
|
224
|
+
actions.append("transfer_ownership")
|
|
225
|
+
|
|
226
|
+
if self._has_storage_capability("get_squad_audit_log"):
|
|
227
|
+
actions.append("view_audit_log")
|
|
228
|
+
|
|
229
|
+
return actions
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# ────────────[ CHIZOBA ]────────────────────────────
|
|
2
|
+
# | Email : chizoba2026@hotmail.com
|
|
3
|
+
# | File : pc_storage_quick.py
|
|
4
|
+
# | License : MIT License © 2026 Chizoba
|
|
5
|
+
# | Brief | Quick functions for PC storage admin
|
|
6
|
+
# ────────────────★─────────────────────────────────
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
Quick functions for PC Storage Admin operations.
|
|
10
|
+
Provides simple one-liner functions for common storage admin tasks.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from typing import Optional, Dict, Any, List
|
|
14
|
+
from .pc_storage_client import PCStorageClient
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def quick_get_squad_storage_info(squad_id: str) -> Optional[Dict[str, Any]]:
|
|
18
|
+
"""
|
|
19
|
+
Quick function to get squad storage information.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
squad_id: Squad ID to retrieve
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
Squad storage information or None if failed
|
|
26
|
+
"""
|
|
27
|
+
try:
|
|
28
|
+
client = PCStorageClient()
|
|
29
|
+
client.authenticate()
|
|
30
|
+
return client.get_squad_storage_info(squad_id)
|
|
31
|
+
except Exception:
|
|
32
|
+
return None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def quick_update_squad_storage(
|
|
36
|
+
squad_id: str,
|
|
37
|
+
name: Optional[str] = None,
|
|
38
|
+
description: Optional[str] = None,
|
|
39
|
+
rating: Optional[int] = None,
|
|
40
|
+
member_limit: Optional[int] = None,
|
|
41
|
+
privacy: Optional[str] = None
|
|
42
|
+
) -> bool:
|
|
43
|
+
"""
|
|
44
|
+
Quick function to update squad storage information.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
squad_id: Squad ID to update
|
|
48
|
+
name: New squad name
|
|
49
|
+
description: New squad description
|
|
50
|
+
rating: New squad rating
|
|
51
|
+
member_limit: New member limit
|
|
52
|
+
privacy: Privacy settings
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
True if successful, False otherwise
|
|
56
|
+
"""
|
|
57
|
+
try:
|
|
58
|
+
client = PCStorageClient()
|
|
59
|
+
client.authenticate()
|
|
60
|
+
result = client.update_squad_storage(
|
|
61
|
+
squad_id=squad_id,
|
|
62
|
+
name=name,
|
|
63
|
+
description=description,
|
|
64
|
+
rating=rating,
|
|
65
|
+
member_limit=member_limit,
|
|
66
|
+
privacy=privacy
|
|
67
|
+
)
|
|
68
|
+
return True
|
|
69
|
+
except Exception:
|
|
70
|
+
return False
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def quick_delete_squad(squad_id: str) -> bool:
|
|
74
|
+
"""
|
|
75
|
+
Quick function to delete a squad (requires storage_admin scope).
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
squad_id: Squad ID to delete
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
True if successful, False otherwise
|
|
82
|
+
"""
|
|
83
|
+
try:
|
|
84
|
+
client = PCStorageClient()
|
|
85
|
+
client.authenticate()
|
|
86
|
+
result = client.delete_squad(squad_id)
|
|
87
|
+
return True
|
|
88
|
+
except Exception:
|
|
89
|
+
return False
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def quick_get_all_squads(limit: int = 50) -> Optional[List[Dict[str, Any]]]:
|
|
93
|
+
"""
|
|
94
|
+
Quick function to get all squads.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
limit: Number of squads to retrieve
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
List of squads or None if failed
|
|
101
|
+
"""
|
|
102
|
+
try:
|
|
103
|
+
client = PCStorageClient()
|
|
104
|
+
client.authenticate()
|
|
105
|
+
result = client.get_all_squads(limit=limit)
|
|
106
|
+
return result.get('squads', []) if isinstance(result, dict) else result
|
|
107
|
+
except Exception:
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def quick_batch_delete_squads(squad_ids: List[str]) -> Dict[str, Any]:
|
|
112
|
+
"""
|
|
113
|
+
Quick function to delete multiple squads.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
squad_ids: List of squad IDs to delete
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
Batch deletion results
|
|
120
|
+
"""
|
|
121
|
+
try:
|
|
122
|
+
client = PCStorageClient()
|
|
123
|
+
client.authenticate()
|
|
124
|
+
return client.batch_delete_squads(squad_ids)
|
|
125
|
+
except Exception as e:
|
|
126
|
+
return {"error": str(e)}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def quick_transfer_squad_ownership(
|
|
130
|
+
squad_id: str,
|
|
131
|
+
new_owner_credential: str
|
|
132
|
+
) -> bool:
|
|
133
|
+
"""
|
|
134
|
+
Quick function to transfer squad ownership.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
squad_id: Squad ID to transfer
|
|
138
|
+
new_owner_credential: New owner's credential
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
True if successful, False otherwise
|
|
142
|
+
"""
|
|
143
|
+
try:
|
|
144
|
+
client = PCStorageClient()
|
|
145
|
+
client.authenticate()
|
|
146
|
+
result = client.transfer_squad_ownership(squad_id, new_owner_credential)
|
|
147
|
+
return True
|
|
148
|
+
except Exception:
|
|
149
|
+
return False
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def quick_get_squad_audit_log(squad_id: str, limit: int = 20) -> Optional[List[Dict[str, Any]]]:
|
|
153
|
+
"""
|
|
154
|
+
Quick function to get squad audit log.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
squad_id: Squad ID to get audit log for
|
|
158
|
+
limit: Number of audit entries to retrieve
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
Audit log entries or None if failed
|
|
162
|
+
"""
|
|
163
|
+
try:
|
|
164
|
+
client = PCStorageClient()
|
|
165
|
+
client.authenticate()
|
|
166
|
+
result = client.get_squad_audit_log(squad_id, limit=limit)
|
|
167
|
+
return result.get('entries', []) if isinstance(result, dict) else result
|
|
168
|
+
except Exception:
|
|
169
|
+
return None
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def quick_squad_management_report(squad_id: str) -> Optional[Dict[str, Any]]:
|
|
173
|
+
"""
|
|
174
|
+
Quick function to generate comprehensive squad management report.
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
squad_id: Squad ID to analyze
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
Comprehensive squad report or None if failed
|
|
181
|
+
"""
|
|
182
|
+
try:
|
|
183
|
+
client = PCStorageClient()
|
|
184
|
+
client.authenticate()
|
|
185
|
+
return client.quick_squad_management_report(squad_id)
|
|
186
|
+
except Exception:
|
|
187
|
+
return None
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def quick_check_storage_capabilities() -> Optional[Dict[str, Any]]:
|
|
191
|
+
"""
|
|
192
|
+
Quick function to check current storage capabilities.
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
Storage capabilities information or None if failed
|
|
196
|
+
"""
|
|
197
|
+
try:
|
|
198
|
+
client = PCStorageClient()
|
|
199
|
+
client.authenticate()
|
|
200
|
+
return client.get_storage_info()
|
|
201
|
+
except Exception:
|
|
202
|
+
return None
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def quick_analyze_squad(squad_id: str) -> Optional[Dict[str, Any]]:
|
|
206
|
+
"""
|
|
207
|
+
Quick function to analyze squad with all available storage data.
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
squad_id: Squad ID to analyze
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
Squad analysis results or None if failed
|
|
214
|
+
"""
|
|
215
|
+
try:
|
|
216
|
+
client = PCStorageClient()
|
|
217
|
+
client.authenticate()
|
|
218
|
+
|
|
219
|
+
# Get comprehensive squad data
|
|
220
|
+
squad_info = client.get_squad_storage_info(squad_id)
|
|
221
|
+
audit_log = client.get_squad_audit_log(squad_id, limit=10)
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
"squad_id": squad_id,
|
|
225
|
+
"squad_info": squad_info,
|
|
226
|
+
"audit_log": audit_log,
|
|
227
|
+
"analysis": {
|
|
228
|
+
"has_data": bool(squad_info),
|
|
229
|
+
"has_audit_log": bool(audit_log),
|
|
230
|
+
"available_actions": client._get_available_actions(squad_id)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
except Exception:
|
|
234
|
+
return None
|
mc5_api_client/platform.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
# ────────────[
|
|
3
|
-
# |
|
|
4
|
-
# | Telegram : kakuzu_f0
|
|
2
|
+
# ────────────[ CHIZOBA ]────────────────────────────
|
|
3
|
+
# | Email : chizoba2026@hotmail.com
|
|
5
4
|
# | File : platform.py
|
|
6
|
-
# | License : MIT License
|
|
5
|
+
# | License : MIT License 2026 Chizoba
|
|
7
6
|
# | Brief : Platform support for MC5 API Client (PC & Android)
|
|
8
7
|
# ────────────────★─────────────────────────────────
|
|
9
8
|
|