Skip to content

Commit acbc431

Browse files
committed
Merge dev into main
2 parents 65afc45 + f849a92 commit acbc431

File tree

18 files changed

+172
-33
lines changed

18 files changed

+172
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# OSBot-Fast-API-Serverless
22
Repo for OSBot-Fast-API-Serverless
33

4-
![Current Release](https://img.shields.io/badge/release-v1.24.0-blue)
4+
![Current Release](https://img.shields.io/badge/release-v1.24.1-blue)

modules/OSBot-Utils

Submodule OSBot-Utils updated 21 files
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
package_name = 'osbot_fast_api_serverless'
12
path=__path__[0]

osbot_fast_api_serverless/fast_api/lambda_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from osbot_aws.aws.lambda_.boto3__lambda import load_dependencies # using the lightweight file (which only has the boto3 calls required to load_dependencies)
22

3-
LAMBDA_DEPENDENCIES = ['osbot-fast-api==v0.28.0', 'mangum']
3+
LAMBDA_DEPENDENCIES = ['osbot-fast-api==v0.31.0', 'mangum==0.19.0']
44

55
load_dependencies(LAMBDA_DEPENDENCIES)
66

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
1-
from osbot_fast_api.api.routes.Fast_API__Routes import Fast_API__Routes
2-
from osbot_fast_api_serverless.utils.Version import version__osbot_fast_api_serverless
1+
from osbot_fast_api.api.routes.Fast_API__Routes import Fast_API__Routes
2+
from osbot_fast_api_serverless.services.info.Service_Info import Service_Info
3+
from osbot_fast_api_serverless.utils.Version import version__osbot_fast_api_serverless
34

4-
ROUTES_PATHS__INFO = ['/info/version']
5+
TAG__ROUTES_INFO = 'info'
6+
ROUTES_PATHS__INFO = [ f'/{TAG__ROUTES_INFO}/health' ,
7+
f'/{TAG__ROUTES_INFO}/server' ,
8+
f'/{TAG__ROUTES_INFO}/status' ,
9+
f'/{TAG__ROUTES_INFO}/version' ,
10+
f'/{TAG__ROUTES_INFO}/versions']
11+
ROUTES_INFO__HEALTH__RETURN_VALUE = {'status': 'ok'}
512

613
class Routes__Info(Fast_API__Routes):
7-
tag :str = 'info'
14+
tag : str = 'info'
15+
service_info: Service_Info
816

17+
def health(self):
18+
return ROUTES_INFO__HEALTH__RETURN_VALUE
19+
20+
def server(self): # Get service versions
21+
return self.service_info.server_info()
22+
23+
def status(self): # Get service status information
24+
return self.service_info.service_info()
25+
26+
def versions(self): # Get service versions
27+
return self.service_info.versions() # todo: this should also include the version from Fast_API
28+
# and see if this should not be inside the /server endpoint
929

1030
def version(self):
11-
return {'version': version__osbot_fast_api_serverless}
31+
return dict(version=version__osbot_fast_api_serverless ) # todo: fix this to get this value from FastAPI app object
1232

13-
1433
def setup_routes(self):
15-
self.add_route_get(self.version)
16-
34+
self.add_route_get(self.health )
35+
self.add_route_get(self.server )
36+
self.add_route_get(self.status )
37+
self.add_route_get(self.version )
38+
self.add_route_get(self.versions)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from osbot_fast_api.utils.Fast_API__Server_Info import fast_api__server_info, Fast_API__Server_Info
2+
from osbot_fast_api_serverless.services.info.schemas.Enum__Service_Environment import Enum__Service_Environment
3+
from osbot_fast_api_serverless.services.info.schemas.Schema__Server__Versions import Schema__Server__Versions
4+
from osbot_fast_api_serverless.services.info.schemas.Schema__Service__Status import Schema__Service__Status
5+
from osbot_utils.type_safe.Type_Safe import Type_Safe
6+
7+
8+
class Service_Info(Type_Safe):
9+
10+
def environment(self): # Determine current environment
11+
import os
12+
if os.getenv('AWS_REGION'):
13+
return Enum__Service_Environment.aws_lambda
14+
else:
15+
return Enum__Service_Environment.local
16+
17+
def service_info(self) -> Schema__Service__Status: # Get current service status
18+
return Schema__Service__Status(environment = self.environment())
19+
20+
def versions(self):
21+
return Schema__Server__Versions()
22+
23+
def server_info(self) -> Fast_API__Server_Info:
24+
return fast_api__server_info

osbot_fast_api_serverless/services/info/__init__.py

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from enum import Enum
2+
3+
4+
class Enum__Service_Environment(str, Enum):
5+
aws_lambda = 'aws-lambda'
6+
local = 'local'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from enum import Enum
2+
3+
class Enum__Service_Status(str, Enum):
4+
operational = 'operational'
5+
degraded = 'degraded'

0 commit comments

Comments
 (0)