fleet-python 0.1.0__py3-none-any.whl → 0.2.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.
Potentially problematic release.
This version of fleet-python might be problematic. Click here for more details.
- examples/browser_control_example.py +51 -0
- fleet/__init__.py +4 -16
- fleet/base.py +74 -0
- fleet/client.py +115 -279
- fleet/env/__init__.py +3 -25
- fleet/env/base.py +50 -318
- fleet/env/client.py +241 -0
- fleet/env/models.py +127 -0
- fleet/models.py +109 -0
- fleet/resources/base.py +23 -0
- fleet/resources/browser.py +18 -0
- fleet/resources/sqlite.py +41 -0
- {fleet_python-0.1.0.dist-info → fleet_python-0.2.0.dist-info}/METADATA +2 -1
- fleet_python-0.2.0.dist-info/RECORD +19 -0
- fleet/config.py +0 -125
- fleet/env/factory.py +0 -446
- fleet/facets/__init__.py +0 -7
- fleet/facets/base.py +0 -223
- fleet/facets/factory.py +0 -29
- fleet/manager_client.py +0 -177
- fleet_python-0.1.0.dist-info/RECORD +0 -17
- {fleet_python-0.1.0.dist-info → fleet_python-0.2.0.dist-info}/WHEEL +0 -0
- {fleet_python-0.1.0.dist-info → fleet_python-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {fleet_python-0.1.0.dist-info → fleet_python-0.2.0.dist-info}/top_level.txt +0 -0
fleet/manager_client.py
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
# Copyright 2025 Fleet AI
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
"""Fleet Manager API Client for per-instance environment management."""
|
|
16
|
-
|
|
17
|
-
import asyncio
|
|
18
|
-
import logging
|
|
19
|
-
from typing import Any, Dict, Optional
|
|
20
|
-
import aiohttp
|
|
21
|
-
from pydantic import BaseModel, Field
|
|
22
|
-
|
|
23
|
-
from .exceptions import (
|
|
24
|
-
FleetAPIError,
|
|
25
|
-
FleetTimeoutError,
|
|
26
|
-
FleetError,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
logger = logging.getLogger(__name__)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class ManagerHealthResponse(BaseModel):
|
|
33
|
-
"""Response model for manager health checks."""
|
|
34
|
-
|
|
35
|
-
status: str = Field(..., description="Health status")
|
|
36
|
-
timestamp: str = Field(..., description="Timestamp")
|
|
37
|
-
service: str = Field(..., description="Service name")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
class TimestampResponse(BaseModel):
|
|
41
|
-
"""Response model for timestamp endpoint."""
|
|
42
|
-
|
|
43
|
-
timestamp: str = Field(..., description="Current timestamp")
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class FleetManagerClient:
|
|
47
|
-
"""Client for interacting with Fleet Manager APIs on individual instances."""
|
|
48
|
-
|
|
49
|
-
def __init__(self, base_url: str):
|
|
50
|
-
"""Initialize the manager client.
|
|
51
|
-
|
|
52
|
-
Args:
|
|
53
|
-
base_url: Base URL for the manager API (e.g., https://instanceid.fleetai.com)
|
|
54
|
-
"""
|
|
55
|
-
self._base_url = base_url.rstrip('/')
|
|
56
|
-
self._session: Optional[aiohttp.ClientSession] = None
|
|
57
|
-
|
|
58
|
-
async def __aenter__(self):
|
|
59
|
-
"""Async context manager entry."""
|
|
60
|
-
await self._ensure_session()
|
|
61
|
-
return self
|
|
62
|
-
|
|
63
|
-
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
64
|
-
"""Async context manager exit."""
|
|
65
|
-
await self.close()
|
|
66
|
-
|
|
67
|
-
async def _ensure_session(self):
|
|
68
|
-
"""Ensure HTTP session is created."""
|
|
69
|
-
if self._session is None or self._session.closed:
|
|
70
|
-
timeout = aiohttp.ClientTimeout(total=30)
|
|
71
|
-
self._session = aiohttp.ClientSession(
|
|
72
|
-
timeout=timeout,
|
|
73
|
-
connector=aiohttp.TCPConnector(limit=10),
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
async def close(self):
|
|
77
|
-
"""Close the HTTP session."""
|
|
78
|
-
if self._session and not self._session.closed:
|
|
79
|
-
await self._session.close()
|
|
80
|
-
self._session = None
|
|
81
|
-
|
|
82
|
-
async def _request(
|
|
83
|
-
self,
|
|
84
|
-
method: str,
|
|
85
|
-
path: str,
|
|
86
|
-
data: Optional[Dict[str, Any]] = None,
|
|
87
|
-
params: Optional[Dict[str, Any]] = None,
|
|
88
|
-
headers: Optional[Dict[str, str]] = None,
|
|
89
|
-
timeout: Optional[float] = None,
|
|
90
|
-
) -> Dict[str, Any]:
|
|
91
|
-
"""Make an HTTP request to the Manager API.
|
|
92
|
-
|
|
93
|
-
Args:
|
|
94
|
-
method: HTTP method (GET, POST, etc.)
|
|
95
|
-
path: API endpoint path
|
|
96
|
-
data: Request body data
|
|
97
|
-
params: Query parameters
|
|
98
|
-
headers: Additional headers
|
|
99
|
-
timeout: Request timeout in seconds
|
|
100
|
-
|
|
101
|
-
Returns:
|
|
102
|
-
Response data as dictionary
|
|
103
|
-
|
|
104
|
-
Raises:
|
|
105
|
-
FleetAPIError: If the API returns an error
|
|
106
|
-
FleetTimeoutError: If request times out
|
|
107
|
-
"""
|
|
108
|
-
await self._ensure_session()
|
|
109
|
-
|
|
110
|
-
url = f"{self._base_url}{path}"
|
|
111
|
-
request_headers = headers or {}
|
|
112
|
-
|
|
113
|
-
try:
|
|
114
|
-
logger.debug(f"Making {method} request to {url}")
|
|
115
|
-
|
|
116
|
-
async with self._session.request(
|
|
117
|
-
method=method,
|
|
118
|
-
url=url,
|
|
119
|
-
json=data,
|
|
120
|
-
params=params,
|
|
121
|
-
headers=request_headers,
|
|
122
|
-
timeout=aiohttp.ClientTimeout(total=timeout or 30),
|
|
123
|
-
) as response:
|
|
124
|
-
response_data = await response.json() if response.content_type == "application/json" else {}
|
|
125
|
-
|
|
126
|
-
if response.status == 200:
|
|
127
|
-
logger.debug(f"Manager API request successful: {response.status}")
|
|
128
|
-
return response_data
|
|
129
|
-
else:
|
|
130
|
-
error_message = response_data.get("detail", f"Manager API request failed with status {response.status}")
|
|
131
|
-
raise FleetAPIError(
|
|
132
|
-
error_message,
|
|
133
|
-
status_code=response.status,
|
|
134
|
-
response_data=response_data,
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
except asyncio.TimeoutError:
|
|
138
|
-
raise FleetTimeoutError(f"Request to {url} timed out")
|
|
139
|
-
|
|
140
|
-
except aiohttp.ClientError as e:
|
|
141
|
-
raise FleetAPIError(f"HTTP client error: {e}")
|
|
142
|
-
|
|
143
|
-
# Health check operations
|
|
144
|
-
async def health_check(self) -> ManagerHealthResponse:
|
|
145
|
-
"""Check the health of the manager API.
|
|
146
|
-
|
|
147
|
-
Returns:
|
|
148
|
-
ManagerHealthResponse object
|
|
149
|
-
"""
|
|
150
|
-
response = await self._request("GET", "/health")
|
|
151
|
-
return ManagerHealthResponse(**response)
|
|
152
|
-
|
|
153
|
-
async def get_timestamp(self) -> TimestampResponse:
|
|
154
|
-
"""Get current timestamp from the manager.
|
|
155
|
-
|
|
156
|
-
Returns:
|
|
157
|
-
TimestampResponse object
|
|
158
|
-
"""
|
|
159
|
-
response = await self._request("GET", "/timestamp")
|
|
160
|
-
return TimestampResponse(**response)
|
|
161
|
-
|
|
162
|
-
async def test_path(self) -> Dict[str, Any]:
|
|
163
|
-
"""Test endpoint to verify path configuration.
|
|
164
|
-
|
|
165
|
-
Returns:
|
|
166
|
-
Test response data
|
|
167
|
-
"""
|
|
168
|
-
response = await self._request("GET", "/test-path")
|
|
169
|
-
return response
|
|
170
|
-
|
|
171
|
-
# Future endpoints can be added here as needed:
|
|
172
|
-
# - log_action()
|
|
173
|
-
# - reset_database()
|
|
174
|
-
# - create_snapshots()
|
|
175
|
-
# - generate_diff()
|
|
176
|
-
# - execute_verifier_function()
|
|
177
|
-
# etc.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
examples/quickstart.py,sha256=AnLlLQYRfrP7y2J69d1HZRlZsjJT-KeBu897MoNfqYM,4671
|
|
2
|
-
fleet/__init__.py,sha256=WhanDP1kC_K84nrEe9ER1iyODW2344wghQ8Rgdi-JmA,1441
|
|
3
|
-
fleet/client.py,sha256=nBjUV901oyR5uE0WAwHEE-xsgyntesGRiLVhVWf793o,12071
|
|
4
|
-
fleet/config.py,sha256=xlKv-gr38oBcyltQiKjgLzxV-JSd3b4x5oxevOjioME,3768
|
|
5
|
-
fleet/exceptions.py,sha256=yG3QWprCw1OnF-vdFBFJWE4m3ftBLBng31Dr__VbjI4,2249
|
|
6
|
-
fleet/manager_client.py,sha256=o01MuTAoeXssI23SSIwsAHM8ck1G6VsOluD_emcpFnE,5900
|
|
7
|
-
fleet/env/__init__.py,sha256=yKJ-35vAVU4VWWkZMDFeElF9uMzsahBm2K-IumOkciU,570
|
|
8
|
-
fleet/env/base.py,sha256=Ry-1t2cyn2EMlpEtO3XJ89FzK7Q471tsZ8WaluIacK8,12046
|
|
9
|
-
fleet/env/factory.py,sha256=BH6ILmc5WvyNanqSf6RqZXR6SgixMoDw5tOnR0PqVhM,13920
|
|
10
|
-
fleet/facets/__init__.py,sha256=oXU7Tkcx1ETlto4mLUwrjj5-5EcsM-lqAqksJMpmDkE,84
|
|
11
|
-
fleet/facets/base.py,sha256=mJAnRiboGWRn5eSjKM6QZTOPDGDiMrl2kwJbONZ3yq0,5400
|
|
12
|
-
fleet/facets/factory.py,sha256=7OecnXJUafsM9mJcNPHXV5djUOUNg8I6p12sfXGCb4g,782
|
|
13
|
-
fleet_python-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
14
|
-
fleet_python-0.1.0.dist-info/METADATA,sha256=I6IGquclMRBeM6IVAKs_uQY-8rC7McfSrE850zCcHfU,3040
|
|
15
|
-
fleet_python-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
-
fleet_python-0.1.0.dist-info/top_level.txt,sha256=AOyXOrBXUjPcH4BumElz_D95kiWKNIpUbUPFP_9gCLk,15
|
|
17
|
-
fleet_python-0.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|