mgraph-ai-service-cache-client 0.1.3__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 mgraph-ai-service-cache-client might be problematic. Click here for more details.

Files changed (51) hide show
  1. mgraph_ai_service_cache_client/client/Cache__Client.py +6 -0
  2. mgraph_ai_service_cache_client/client/Cache__Client__Config.py +7 -0
  3. mgraph_ai_service_cache_client/client/Cache__Client__Health_Checks.py +38 -0
  4. mgraph_ai_service_cache_client/client/Cache__Client__Requests.py +50 -0
  5. mgraph_ai_service_cache_client/client_builder/Fast_API__Client__Builder.py +49 -0
  6. mgraph_ai_service_cache_client/client_contract/Service__Fast_API__Client.py +77 -0
  7. mgraph_ai_service_cache_client/client_contract/Service__Fast_API__Client__Config.py +14 -0
  8. mgraph_ai_service_cache_client/client_contract/Service__Fast_API__Client__Requests.py +146 -0
  9. mgraph_ai_service_cache_client/client_contract/__init__.py +1 -0
  10. mgraph_ai_service_cache_client/client_contract/admin_storage/Service__Fast_API__Client__Admin__Storage.py +113 -0
  11. mgraph_ai_service_cache_client/client_contract/auth/Service__Fast_API__Client__Set_Cookie.py +35 -0
  12. mgraph_ai_service_cache_client/client_contract/data/Service__Fast_API__Client__Data.py +17 -0
  13. mgraph_ai_service_cache_client/client_contract/data/Service__Fast_API__Client__Data__Delete.py +63 -0
  14. mgraph_ai_service_cache_client/client_contract/data/Service__Fast_API__Client__Data__Retrieve.py +87 -0
  15. mgraph_ai_service_cache_client/client_contract/data_store/Service__Fast_API__Client__Data__Store.py +148 -0
  16. mgraph_ai_service_cache_client/client_contract/delete/Service__Fast_API__Client__File__Delete.py +22 -0
  17. mgraph_ai_service_cache_client/client_contract/exists/Service__Fast_API__Client__File__Exists.py +22 -0
  18. mgraph_ai_service_cache_client/client_contract/info/Service__Fast_API__Client__Info.py +64 -0
  19. mgraph_ai_service_cache_client/client_contract/namespace/Service__Fast_API__Client__Namespace.py +48 -0
  20. mgraph_ai_service_cache_client/client_contract/retrieve/Service__Fast_API__Client__File__Retrieve.py +169 -0
  21. mgraph_ai_service_cache_client/client_contract/server/Service__Fast_API__Client__Server.py +35 -0
  22. mgraph_ai_service_cache_client/client_contract/store/Service__Fast_API__Client__File__Store.py +104 -0
  23. mgraph_ai_service_cache_client/client_contract/zip/Service__Fast_API__Client__Zip.py +129 -0
  24. mgraph_ai_service_cache_client/schemas/cache/Schema__Cache__Exists__Response.py +1 -1
  25. mgraph_ai_service_cache_client/schemas/cache/enums/Enum__Cache__Store__Strategy.py +3 -0
  26. mgraph_ai_service_cache_client/schemas/client/Cache__Client__Requests__Result.py +26 -0
  27. mgraph_ai_service_cache_client/schemas/client/health_checks/Client__Check__Target_Server__Auth.py +7 -0
  28. mgraph_ai_service_cache_client/schemas/client/health_checks/Client__Check__Target_Server__Status.py +11 -0
  29. mgraph_ai_service_cache_client/schemas/client_builder/Schema__Fast_API__Client__Server__Details.py +9 -0
  30. mgraph_ai_service_cache_client/schemas/client_builder/__init__.py +0 -0
  31. mgraph_ai_service_cache_client/schemas/consts/consts__Cache_Client.py +3 -0
  32. mgraph_ai_service_cache_client/schemas/errors/Schema__Cache__Error__Gone.py +2 -2
  33. mgraph_ai_service_cache_client/schemas/errors/Schema__Cache__Error__Not_Found.py +4 -4
  34. mgraph_ai_service_cache_client/version +1 -1
  35. {mgraph_ai_service_cache_client-0.1.3.dist-info → mgraph_ai_service_cache_client-0.2.0.dist-info}/METADATA +3 -2
  36. {mgraph_ai_service_cache_client-0.1.3.dist-info → mgraph_ai_service_cache_client-0.2.0.dist-info}/RECORD +41 -22
  37. mgraph_ai_service_cache_client/config.py +0 -6
  38. mgraph_ai_service_cache_client/fast_api/Cache_Client__Fast_API.py +0 -15
  39. mgraph_ai_service_cache_client/fast_api/lambda_handler.py +0 -26
  40. mgraph_ai_service_cache_client/fast_api/routes/Routes__Info.py +0 -32
  41. mgraph_ai_service_cache_client/service/info/Service_Info.py +0 -23
  42. mgraph_ai_service_cache_client/service/info/schemas/Enum__Service_Environment.py +0 -6
  43. mgraph_ai_service_cache_client/service/info/schemas/Enum__Service_Status.py +0 -5
  44. mgraph_ai_service_cache_client/service/info/schemas/Schema__Server__Versions.py +0 -15
  45. mgraph_ai_service_cache_client/service/info/schemas/Schema__Service__Status.py +0 -14
  46. mgraph_ai_service_cache_client/utils/deploy/Deploy__Service.py +0 -20
  47. /mgraph_ai_service_cache_client/{fast_api → client}/__init__.py +0 -0
  48. /mgraph_ai_service_cache_client/{fast_api/routes → client_builder}/__init__.py +0 -0
  49. /mgraph_ai_service_cache_client/{service → schemas/client}/__init__.py +0 -0
  50. {mgraph_ai_service_cache_client-0.1.3.dist-info → mgraph_ai_service_cache_client-0.2.0.dist-info}/LICENSE +0 -0
  51. {mgraph_ai_service_cache_client-0.1.3.dist-info → mgraph_ai_service_cache_client-0.2.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,6 @@
1
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
2
+ from mgraph_ai_service_cache_client.client.Cache__Client__Config import Cache__Client__Config
3
+
4
+
5
+ class Cache__Client(Type_Safe):
6
+ config: Cache__Client__Config
@@ -0,0 +1,7 @@
1
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
2
+ from osbot_utils.type_safe.primitives.domains.web.safe_str.Safe_Str__Url import Safe_Str__Url
3
+
4
+ URL__TARGET_SERVER__DEV = "https://cache.dev.mgraph.ai"
5
+
6
+ class Cache__Client__Config(Type_Safe):
7
+ target_server : Safe_Str__Url = URL__TARGET_SERVER__DEV
@@ -0,0 +1,38 @@
1
+ from osbot_utils.decorators.methods.cache_on_self import cache_on_self
2
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
3
+ from osbot_utils.utils.Misc import list_set
4
+ from mgraph_ai_service_cache_client.client.Cache__Client__Config import Cache__Client__Config
5
+ from mgraph_ai_service_cache_client.client.Cache__Client__Requests import Cache__Client__Requests
6
+ from mgraph_ai_service_cache_client.schemas.client.health_checks.Client__Check__Target_Server__Status import Client__Check__Target_Server__Status
7
+ from mgraph_ai_service_cache_client.schemas.client.health_checks.Client__Check__Target_Server__Auth import Client__Check__Target_Server__Auth
8
+
9
+
10
+ class Cache__Client__Health_Checks(Type_Safe):
11
+ config : Cache__Client__Config
12
+
13
+ @cache_on_self
14
+ def client__requests(self):
15
+ return Cache__Client__Requests(config=self.config)
16
+
17
+ def check__target_server__status(self) -> Client__Check__Target_Server__Status:
18
+ path = "/openapi.json" # in Fast_API this endpoint has no auth
19
+ result = self.client__requests().get(path)
20
+ openapi_json = result.json
21
+ success = list_set(openapi_json) == ['components', 'info', 'openapi', 'paths']
22
+
23
+ status_kwargs = dict(duration = result.duration ,
24
+ success = success ,
25
+ target_server = self.config.target_server)
26
+ return Client__Check__Target_Server__Status(**status_kwargs)
27
+
28
+ def check__target_server__auth(self) -> Client__Check__Target_Server__Auth:
29
+ with self.client__requests() as _:
30
+ found_key_name = _.auth__key_name () is not None
31
+ found_key_value = _.auth__key_value() is not None
32
+ path = '/info/health'
33
+ result = self.client__requests().get(path)
34
+ key_valid_in_target_server = result.json == {'status': 'ok'}
35
+ auth_kwargs = dict(found_key_name = found_key_name ,
36
+ found_key_value = found_key_value,
37
+ key_valid_in_target_server = key_valid_in_target_server)
38
+ return Client__Check__Target_Server__Auth(**auth_kwargs)
@@ -0,0 +1,50 @@
1
+ import requests
2
+ from osbot_utils.helpers.duration.decorators.capture_duration import capture_duration
3
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
4
+ from osbot_utils.utils.Env import get_env
5
+ from osbot_utils.utils.Http import url_join_safe
6
+ from mgraph_ai_service_cache_client.client.Cache__Client__Config import Cache__Client__Config
7
+ from mgraph_ai_service_cache_client.schemas.client.Cache__Client__Requests__Result import Cache__Client__Requests__Result
8
+ from mgraph_ai_service_cache_client.schemas.consts.consts__Cache_Client import ENV_VAR__AUTH__TARGET_SERVER__CACHE_SERVICE__KEY_NAME, ENV_VAR__AUTH__TARGET_SERVER__CACHE_SERVICE__KEY_VALUE
9
+
10
+
11
+ class Cache__Client__Requests(Type_Safe):
12
+ config: Cache__Client__Config
13
+
14
+ def auth__key_name(self):
15
+ return get_env(ENV_VAR__AUTH__TARGET_SERVER__CACHE_SERVICE__KEY_NAME)
16
+
17
+ def auth__key_value(self):
18
+ return get_env(ENV_VAR__AUTH__TARGET_SERVER__CACHE_SERVICE__KEY_VALUE)
19
+
20
+ def auth_headers(self):
21
+ key_name = self.auth__key_name()
22
+ key_value = self.auth__key_value()
23
+ if key_name and key_value:
24
+ return { key_name: key_value }
25
+ return {}
26
+
27
+ def headers(self):
28
+ return { **self.auth_headers() } # location to add more requests headers (if needed)
29
+
30
+ def get(self, path):
31
+ target_server = self.config.target_server
32
+ url = url_join_safe(target_server, path)
33
+ headers = self.auth_headers()
34
+ with capture_duration() as duration:
35
+ response = requests.get(url, headers=headers)
36
+
37
+
38
+ content_type = response.headers.get('content-type')
39
+ result_kwargs = dict(content_type = content_type ,
40
+ duration = duration.seconds ,
41
+ path = path ,
42
+ status_code = response.status_code,
43
+ target_server = target_server )
44
+
45
+ if 'json' in content_type: result_kwargs['json' ] = response.json()
46
+ elif 'text' in content_type: result_kwargs['text' ] = response.text
47
+ else: result_kwargs['content'] = response.content
48
+
49
+ return Cache__Client__Requests__Result(**result_kwargs)
50
+
@@ -0,0 +1,49 @@
1
+ from osbot_fast_api.client.Fast_API__Client__Generator import Fast_API__Client__Generator
2
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
3
+ from osbot_utils.type_safe.type_safe_core.decorators.type_safe import type_safe
4
+ from osbot_utils.utils.Env import get_env
5
+ from mgraph_ai_service_cache.fast_api.Service__Fast_API import Service__Fast_API
6
+ from mgraph_ai_service_cache_client import client_contract
7
+ from mgraph_ai_service_cache_client.client_contract.Service__Fast_API__Client import Service__Fast_API__Client
8
+ from mgraph_ai_service_cache_client.schemas.client_builder.Schema__Fast_API__Client__Server__Details import Schema__Fast_API__Client__Server__Details
9
+ from mgraph_ai_service_cache_client.schemas.consts.consts__Cache_Client import ENV_VAR__AUTH__TARGET_SERVER__CACHE_SERVICE__KEY_VALUE, ENV_VAR__AUTH__TARGET_SERVER__CACHE_SERVICE__KEY_NAME, ENV_VAR__URL__TARGET_SERVER__CACHE_SERVICE
10
+
11
+
12
+ class Fast_API__Client__Builder(Type_Safe):
13
+
14
+ def __init__(self, **kwargs):
15
+ super().__init__(**kwargs)
16
+ self.cache_service__fast_api = Service__Fast_API().setup()
17
+ self.generator = Fast_API__Client__Generator(fast_api=self.cache_service__fast_api)
18
+
19
+ def create_client_files(self):
20
+ with self.generator as _:
21
+ output_dir = self.target_folder()
22
+ saved_files = _.save_client_files(output_dir=output_dir)
23
+ return sorted(saved_files)
24
+
25
+ def target_folder(self):
26
+ return client_contract.path
27
+
28
+ @type_safe
29
+ def configure_client(self, service_client: Service__Fast_API__Client):
30
+ with self.server_details() as _:
31
+ if _.configured:
32
+ service_client.config.api_key = _.api_key
33
+ service_client.config.api_key_header = _.api_key_header
34
+ service_client.config.base_url = _.base_url
35
+ return _
36
+
37
+ def server_details(self) -> Schema__Fast_API__Client__Server__Details:
38
+ api_key = get_env(ENV_VAR__AUTH__TARGET_SERVER__CACHE_SERVICE__KEY_VALUE)
39
+ api_key_header = get_env(ENV_VAR__AUTH__TARGET_SERVER__CACHE_SERVICE__KEY_NAME )
40
+ base_url = get_env(ENV_VAR__URL__TARGET_SERVER__CACHE_SERVICE )
41
+ configured = all([api_key, api_key_header, base_url])
42
+
43
+ kwargs = dict(api_key = api_key ,
44
+ api_key_header = api_key_header ,
45
+ base_url = base_url ,
46
+ configured = configured )
47
+ return Schema__Fast_API__Client__Server__Details(**kwargs)
48
+
49
+
@@ -0,0 +1,77 @@
1
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
2
+ from osbot_utils.decorators.methods.cache_on_self import cache_on_self
3
+ from .Service__Fast_API__Client__Config import Service__Fast_API__Client__Config
4
+ from .Service__Fast_API__Client__Requests import Service__Fast_API__Client__Requests
5
+ from .store.Service__Fast_API__Client__File__Store import Service__Fast_API__Client__File__Store
6
+ from .retrieve.Service__Fast_API__Client__File__Retrieve import Service__Fast_API__Client__File__Retrieve
7
+ from .exists.Service__Fast_API__Client__File__Exists import Service__Fast_API__Client__File__Exists
8
+ from .delete.Service__Fast_API__Client__File__Delete import Service__Fast_API__Client__File__Delete
9
+ from .data_store.Service__Fast_API__Client__Data__Store import Service__Fast_API__Client__Data__Store
10
+ from .data.Service__Fast_API__Client__Data import Service__Fast_API__Client__Data
11
+ from .zip.Service__Fast_API__Client__Zip import Service__Fast_API__Client__Zip
12
+ from .namespace.Service__Fast_API__Client__Namespace import Service__Fast_API__Client__Namespace
13
+ from .admin_storage.Service__Fast_API__Client__Admin__Storage import Service__Fast_API__Client__Admin__Storage
14
+ from .server.Service__Fast_API__Client__Server import Service__Fast_API__Client__Server
15
+ from .info.Service__Fast_API__Client__Info import Service__Fast_API__Client__Info
16
+ #from .auth.Service__Fast_API__Client__Auth import Service__Fast_API__Client__Auth # todo see why this is added here (but file is not created on disk)
17
+
18
+ class Service__Fast_API__Client(Type_Safe):
19
+ config : Service__Fast_API__Client__Config
20
+ _requests: Service__Fast_API__Client__Requests = None
21
+
22
+ def __init__(self, **kwargs):
23
+ super().__init__(**kwargs) # Initialize request handler with config
24
+ if not self._requests:
25
+ self._requests = Service__Fast_API__Client__Requests(config=self.config)
26
+
27
+ @cache_on_self
28
+ def requests(self) -> Service__Fast_API__Client__Requests: # Access the unified request handler
29
+ return self._requests
30
+
31
+ @cache_on_self
32
+ def store(self) -> Service__Fast_API__Client__File__Store: # Access store operations
33
+ return Service__Fast_API__Client__File__Store(_client=self)
34
+
35
+ @cache_on_self
36
+ def retrieve(self) -> Service__Fast_API__Client__File__Retrieve: # Access retrieve operations
37
+ return Service__Fast_API__Client__File__Retrieve(_client=self)
38
+
39
+ @cache_on_self
40
+ def exists(self) -> Service__Fast_API__Client__File__Exists: # Access exists operations
41
+ return Service__Fast_API__Client__File__Exists(_client=self)
42
+
43
+ @cache_on_self
44
+ def delete(self) -> Service__Fast_API__Client__File__Delete: # Access delete operations
45
+ return Service__Fast_API__Client__File__Delete(_client=self)
46
+
47
+ @cache_on_self
48
+ def data_store(self) -> Service__Fast_API__Client__Data__Store: # Access data_store operations
49
+ return Service__Fast_API__Client__Data__Store(_client=self)
50
+
51
+ @cache_on_self
52
+ def data(self) -> Service__Fast_API__Client__Data: # Access data operations
53
+ return Service__Fast_API__Client__Data(_client=self)
54
+
55
+ @cache_on_self
56
+ def zip(self) -> Service__Fast_API__Client__Zip: # Access zip operations
57
+ return Service__Fast_API__Client__Zip(_client=self)
58
+
59
+ @cache_on_self
60
+ def namespace(self) -> Service__Fast_API__Client__Namespace: # Access namespace operations
61
+ return Service__Fast_API__Client__Namespace(_client=self)
62
+
63
+ @cache_on_self
64
+ def admin_storage(self) -> Service__Fast_API__Client__Admin__Storage: # Access admin_storage operations
65
+ return Service__Fast_API__Client__Admin__Storage(_client=self)
66
+
67
+ @cache_on_self
68
+ def server(self) -> Service__Fast_API__Client__Server: # Access server operations
69
+ return Service__Fast_API__Client__Server(_client=self)
70
+
71
+ @cache_on_self
72
+ def info(self) -> Service__Fast_API__Client__Info: # Access info operations
73
+ return Service__Fast_API__Client__Info(_client=self)
74
+
75
+ # @cache_on_self
76
+ # def auth(self) -> Service__Fast_API__Client__Auth: # Access auth operations
77
+ # return Service__Fast_API__Client__Auth(_client=self)
@@ -0,0 +1,14 @@
1
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
2
+ from osbot_utils.type_safe.primitives.domains.web.safe_str.Safe_Str__Url import Safe_Str__Url
3
+ from osbot_utils.type_safe.primitives.domains.identifiers.safe_str.Safe_Str__Id import Safe_Str__Id
4
+ from typing import Optional
5
+
6
+ class Service__Fast_API__Client__Config(Type_Safe):
7
+ base_url : Safe_Str__Url = "http://localhost:8000" # Default to local
8
+ api_key : Optional[str] = None # Optional API key
9
+ api_key_header : str = "X-API-Key" # Header name for API key
10
+ timeout : int = 30 # Request timeout in seconds
11
+ verify_ssl : bool = True # Verify SSL certificates
12
+ # Service-specific configuration can be added here
13
+ service_name : Safe_Str__Id = "Service__Fast_API"
14
+ service_version : str = "v0.5.67"
@@ -0,0 +1,146 @@
1
+ from enum import Enum
2
+ from typing import Any, Optional, Dict, Union, List
3
+ import requests
4
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
5
+
6
+ class Enum__Client__Mode(str, Enum):
7
+ REMOTE = "remote" # HTTP calls to deployed service
8
+ IN_MEMORY = "in_memory" # FastAPI TestClient (same process)
9
+ LOCAL_SERVER = "local_server" # Fast_API_Server (local HTTP)
10
+
11
+ class Service__Fast_API__Client__Requests__Result(Type_Safe):
12
+ status_code : int
13
+ #json : Optional[Dict] = None # BUG, mising list
14
+ json : Union[Dict,List] = None
15
+ text : Optional[str] = None
16
+ content : bytes = b""
17
+ #headers : Dict[str, str] = {} # BUG: we can't do this with Type_Safe (this will be allocated on __init__)
18
+ headers : Dict[str, str]
19
+ path : str = ""
20
+
21
+ class Service__Fast_API__Client__Requests(Type_Safe):
22
+ config : Any # Service__Fast_API__Client__Config
23
+ mode : Enum__Client__Mode = Enum__Client__Mode.REMOTE
24
+ _app : Optional[Any] = None # FastAPI app for in-memory
25
+ _server : Optional[Any] = None # Fast_API_Server for local
26
+ _test_client : Optional[Any] = None # TestClient for in-memory
27
+ _session : Optional[requests.Session] = None # Session for remote
28
+
29
+ def __init__(self, **kwargs):
30
+ super().__init__(**kwargs)
31
+ self._setup_mode()
32
+
33
+ def _setup_mode(self): # Initialize the appropriate execution backend
34
+
35
+ if self._app: # In-memory mode with TestClient
36
+ self.mode = Enum__Client__Mode.IN_MEMORY
37
+ from fastapi.testclient import TestClient
38
+ self._test_client = TestClient(self._app)
39
+
40
+ elif self._server: # Local server mode
41
+ self.mode = Enum__Client__Mode.LOCAL_SERVER
42
+ from osbot_fast_api.utils.Fast_API_Server import Fast_API_Server
43
+ if not isinstance(self._server, Fast_API_Server):
44
+ self._server = Fast_API_Server(app=self._server)
45
+ self._server.start()
46
+
47
+ else: # Remote mode
48
+ self.mode = Enum__Client__Mode.REMOTE
49
+ self._session = requests.Session()
50
+ self._configure_session()
51
+
52
+ def _configure_session(self): # Configure session for remote calls
53
+ if self._session: # Add any auth headers from config
54
+ if hasattr(self.config, 'api_key') and self.config.api_key:
55
+ self._session.headers['Authorization'] = f'Bearer {self.config.api_key}'
56
+
57
+ def execute(self, method : str , # HTTP method (GET, POST, etc)
58
+ path : str , # Endpoint path
59
+ body : Any = None, # Request body
60
+ headers : Optional[Dict] = None # Additional headers
61
+ ) -> Service__Fast_API__Client__Requests__Result: # Execute request transparently based on mode
62
+ # Merge headers
63
+ request_headers = {**self.auth_headers(), **(headers or {})}
64
+ # Execute based on mode
65
+ if self.mode == Enum__Client__Mode.IN_MEMORY:
66
+ response = self._execute_in_memory(method, path, body, request_headers)
67
+ elif self.mode == Enum__Client__Mode.LOCAL_SERVER:
68
+ response = self._execute_local_server(method, path, body, request_headers)
69
+ else:
70
+ response = self._execute_remote(method, path, body, request_headers)
71
+ # Convert to unified result
72
+ return self._build_result(response, path)
73
+
74
+ def _execute_in_memory(self, method : str , # HTTP method
75
+ path : str , # Endpoint path
76
+ body : Any , # Request body
77
+ headers : Dict # Headers
78
+ ): # Execute using FastAPI TestClient
79
+ method_func = getattr(self._test_client, method.lower())
80
+ if body:
81
+ return method_func(path, json=body, headers=headers)
82
+ else:
83
+ return method_func(path, headers=headers)
84
+
85
+ def _execute_local_server(self, method : str , # HTTP method
86
+ path : str , # Endpoint path
87
+ body : Any , # Request body
88
+ headers : Dict # Headers
89
+ ): # Execute using local Fast_API_Server
90
+ url = f"{self._server.url()}{path}"
91
+ method_func = getattr(requests, method.lower())
92
+ if body:
93
+ return method_func(url, json=body, headers=headers)
94
+ else:
95
+ return method_func(url, headers=headers)
96
+
97
+ def _execute_remote(self, method : str , # HTTP method
98
+ path : str , # Endpoint path
99
+ body : Any , # Request body
100
+ headers : Dict # Headers
101
+ ): # Execute using requests to remote service
102
+ url = f"{self.config.base_url}{path}"
103
+ method_func = getattr(self._session, method.lower())
104
+ if body:
105
+ if type(body) is bytes: # todo: BUG need to support submitting bytes like how we are doing here
106
+ headers["Content-Type"]= "application/octet-stream" # we also need to set this content header
107
+ return method_func(url, data=body, headers=headers) #
108
+ else: #
109
+ return method_func(url, json=body, headers=headers)
110
+ else:
111
+ return method_func(url, headers=headers)
112
+
113
+ def _build_result(self, response , # Response object
114
+ path # Path requested
115
+ ) -> Service__Fast_API__Client__Requests__Result: # Convert any response type to unified result
116
+
117
+ json_data = None
118
+ text_data = None
119
+ # Try to extract JSON
120
+ try:
121
+ json_data = response.json()
122
+ except:
123
+ pass
124
+ # Try to extract text
125
+ try:
126
+ text_data = response.text
127
+ except:
128
+ pass
129
+
130
+ return Service__Fast_API__Client__Requests__Result(
131
+ status_code = response.status_code ,
132
+ json = json_data ,
133
+ text = text_data ,
134
+ content = response.content if hasattr(response, 'content') else b"",
135
+ headers = dict(response.headers) if hasattr(response, 'headers') else {},
136
+ path = path
137
+ )
138
+
139
+ def auth_headers(self) -> Dict[str, str]: # Get authentication headers from config
140
+ headers = {}
141
+ # Add API key if configured
142
+ if hasattr(self.config, 'api_key_header') and hasattr(self.config, 'api_key'):
143
+ if self.config.api_key_header and self.config.api_key:
144
+ headers[self.config.api_key_header] = self.config.api_key
145
+
146
+ return headers
@@ -0,0 +1 @@
1
+ path = __path__[0]
@@ -0,0 +1,113 @@
1
+ from typing import Any, Optional, Dict
2
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
3
+
4
+ class Service__Fast_API__Client__Admin__Storage(Type_Safe):
5
+ _client: Any # Reference to main client
6
+
7
+ @property
8
+ def requests(self): # Access the unified request handler
9
+ return self._client.requests()
10
+
11
+ def bucket_name(self) -> Dict: # Auto-generated from endpoint get__bucket_name
12
+ # Build path
13
+ path = "/admin/storage/bucket-name"
14
+ body = None
15
+ # Execute request
16
+ result = self.requests.execute(
17
+ method = "GET",
18
+ path = path,
19
+ body = body
20
+ )
21
+ # Return response data
22
+ return result.json if result.json else result.text
23
+
24
+ def file__exists(self, path: Any) -> Dict: # Auto-generated from endpoint get__file__exists
25
+ # Build path
26
+ path = f"/admin/storage/file/exists/{path:path}"
27
+ body = None
28
+ # Execute request
29
+ result = self.requests.execute(
30
+ method = "GET",
31
+ path = path,
32
+ body = body
33
+ )
34
+ # Return response data
35
+ return result.json if result.json else result.text
36
+
37
+ def file__bytes(self, path: Any) -> Dict: # Auto-generated from endpoint get__file__bytes
38
+ # Build path
39
+ path = f"/admin/storage/file/bytes/{path:path}"
40
+ body = None
41
+ # Execute request
42
+ result = self.requests.execute(
43
+ method = "GET",
44
+ path = path,
45
+ body = body
46
+ )
47
+ # Return response data
48
+ return result.json if result.json else result.text
49
+
50
+ def file__json(self, path: Any) -> Dict: # Auto-generated from endpoint get__file__json
51
+ # Build path
52
+ path = f"/admin/storage/file/json/{path:path}"
53
+ body = None
54
+ # Execute request
55
+ result = self.requests.execute(
56
+ method = "GET",
57
+ path = path,
58
+ body = body
59
+ )
60
+ # Return response data
61
+ return result.json if result.json else result.text
62
+
63
+ def files__parent_path(self, path: Optional[str] = None, return_full_path: Optional[bool] = None) -> Dict: # Auto-generated from endpoint get__files__parent_path
64
+ # Build path
65
+ path = "/admin/storage/files/parent-path"
66
+ body = None
67
+ # Execute request
68
+ result = self.requests.execute(
69
+ method = "GET",
70
+ path = path,
71
+ body = body
72
+ )
73
+ # Return response data
74
+ return result.json if result.json else result.text
75
+
76
+ def files__all__path(self, path: str) -> Dict: # Auto-generated from endpoint get__files__all__path
77
+ # Build path
78
+ path = f"/admin/storage/files/all/{path:path}"
79
+ body = None
80
+ # Execute request
81
+ result = self.requests.execute(
82
+ method = "GET",
83
+ path = path,
84
+ body = body
85
+ )
86
+ # Return response data
87
+ return result.json if result.json else result.text
88
+
89
+ def folders(self, path: Optional[str] = None, return_full_path: Optional[bool] = None) -> Dict: # Auto-generated from endpoint get__folders
90
+ # Build path
91
+ path = "/admin/storage/folders"
92
+ body = None
93
+ # Execute request
94
+ result = self.requests.execute(
95
+ method = "GET",
96
+ path = path,
97
+ body = body
98
+ )
99
+ # Return response data
100
+ return result.json if result.json else result.text
101
+
102
+ def delete__file(self, path: str) -> Dict: # Auto-generated from endpoint delete__delete__file
103
+ # Build path
104
+ path = f"/admin/storage/{path:path}"
105
+ body = None
106
+ # Execute request
107
+ result = self.requests.execute(
108
+ method = "DELETE",
109
+ path = path,
110
+ body = body
111
+ )
112
+ # Return response data
113
+ return result.json if result.json else result.text
@@ -0,0 +1,35 @@
1
+ from typing import Any, Optional, Dict
2
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
3
+
4
+ class Service__Fast_API__Client__Set_Cookie(Type_Safe):
5
+ _client: Any # Reference to main client
6
+
7
+ @property
8
+ def requests(self): # Access the unified request handler
9
+ return self._client.requests()
10
+
11
+ def set_cookie_form(self) -> Dict: # Auto-generated from endpoint get__set_cookie_form
12
+ # Build path
13
+ path = "/auth/set-cookie-form"
14
+ body = None
15
+ # Execute request
16
+ result = self.requests.execute(
17
+ method = "GET",
18
+ path = path,
19
+ body = body
20
+ )
21
+ # Return response data
22
+ return result.json if result.json else result.text
23
+
24
+ def set_auth_cookie(self) -> Dict: # Auto-generated from endpoint post__set_auth_cookie
25
+ # Build path
26
+ path = "/auth/set-auth-cookie"
27
+ body = None
28
+ # Execute request
29
+ result = self.requests.execute(
30
+ method = "POST",
31
+ path = path,
32
+ body = body
33
+ )
34
+ # Return response data
35
+ return result.json if result.json else result.text
@@ -0,0 +1,17 @@
1
+ from typing import Any
2
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
3
+ from osbot_utils.decorators.methods.cache_on_self import cache_on_self
4
+ from .Service__Fast_API__Client__Data__Retrieve import Service__Fast_API__Client__Data__Retrieve
5
+ from .Service__Fast_API__Client__Data__Delete import Service__Fast_API__Client__Data__Delete
6
+
7
+ class Service__Fast_API__Client__Data(Type_Safe):
8
+ _client: Any # Reference to main client
9
+
10
+ @cache_on_self
11
+ def retrieve(self) -> Service__Fast_API__Client__Data__Retrieve: # Access retrieve operations
12
+ return Service__Fast_API__Client__Data__Retrieve(_client=self._client)
13
+
14
+ @cache_on_self
15
+ def delete(self) -> Service__Fast_API__Client__Data__Delete: # Access delete operations
16
+ return Service__Fast_API__Client__Data__Delete(_client=self._client)
17
+
@@ -0,0 +1,63 @@
1
+ from typing import Any, Dict
2
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
3
+ from mgraph_ai_service_cache_client.schemas.cache.enums.Enum__Cache__Data_Type import Enum__Cache__Data_Type
4
+
5
+
6
+ class Service__Fast_API__Client__Data__Delete(Type_Safe):
7
+ _client: Any # Reference to main client
8
+
9
+ @property
10
+ def requests(self): # Access the unified request handler
11
+ return self._client.requests()
12
+
13
+ def delete__all__data__files(self, cache_id: str, namespace: str) -> Dict: # Auto-generated from endpoint delete__delete__all__data__files
14
+ # Build path
15
+ path = f"/{{namespace}}/cache/{{cache_id}}/data/delete/all"
16
+ body = None
17
+ # Execute request
18
+ result = self.requests.execute(
19
+ method = "DELETE",
20
+ path = path,
21
+ body = body
22
+ )
23
+ # Return response data
24
+ return result.json if result.json else result.text
25
+
26
+ def delete__all__data__files__with__key(self, cache_id: str, namespace: str, data_key: str) -> Dict: # Auto-generated from endpoint delete__delete__all__data__files__with__key
27
+ # Build path
28
+ path = f"/{{namespace}}/cache/{{cache_id}}/data/delete/all/{data_key:path}"
29
+ body = None
30
+ # Execute request
31
+ result = self.requests.execute(
32
+ method = "DELETE",
33
+ path = path,
34
+ body = body
35
+ )
36
+ # Return response data
37
+ return result.json if result.json else result.text
38
+
39
+ def delete__data__file__with__id(self, cache_id: str, namespace: str, data_type: Enum__Cache__Data_Type, data_file_id: str) -> Dict: # Auto-generated from endpoint delete__delete__data__file__with__id
40
+ # Build path
41
+ path = f"/{{namespace}}/cache/{{cache_id}}/data/delete/{{data_type}}/{{data_file_id}}"
42
+ body = None
43
+ # Execute request
44
+ result = self.requests.execute(
45
+ method = "DELETE",
46
+ path = path,
47
+ body = body
48
+ )
49
+ # Return response data
50
+ return result.json if result.json else result.text
51
+
52
+ def delete__data__file__with__id_and_key(self, cache_id: str, namespace: str, data_type: Enum__Cache__Data_Type, data_key: str, data_file_id: str) -> Dict: # Auto-generated from endpoint delete__delete__data__file__with__id_and_key
53
+ # Build path
54
+ path = f"/{{namespace}}/cache/{{cache_id}}/data/delete/{{data_type}}/{data_key:path}/{{data_file_id}}"
55
+ body = None
56
+ # Execute request
57
+ result = self.requests.execute(
58
+ method = "DELETE",
59
+ path = path,
60
+ body = body
61
+ )
62
+ # Return response data
63
+ return result.json if result.json else result.text