generated from owasp-sbot/OSBot__Repo_Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wired up the saving of workflow files to S3
- Loading branch information
Showing
13 changed files
with
131 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from osbot_utils.utils.Env import get_env | ||
from osbot_utils.base_classes.Type_Safe import Type_Safe | ||
|
||
|
||
DEFAULT__SERVERLESS_FLOWS__AWS_ACCOUNT_ID = '0000111100001111' | ||
ENV_NAME__SERVERLESS_FLOWS__USE_LOCAL_STACK = 'SERVERLESS_FLOWS__USE_LOCAL_STACK' | ||
|
||
class Serverless_Flows__Server_Config(Type_Safe): | ||
aws_account_id : str = DEFAULT__SERVERLESS_FLOWS__AWS_ACCOUNT_ID | ||
use_local_stack : bool = False | ||
|
||
def setup(self): | ||
self.use_local_stack = get_env(ENV_NAME__SERVERLESS_FLOWS__USE_LOCAL_STACK) == 'True' or self.use_local_stack | ||
self.aws_account_id = get_env('AWS_ACCOUNT_ID') or self.aws_account_id | ||
return self | ||
|
||
def reset(self): | ||
self.aws_account_id = DEFAULT__SERVERLESS_FLOWS__AWS_ACCOUNT_ID | ||
self.use_local_stack = False | ||
return self | ||
|
||
serverless_flows__server_config = Serverless_Flows__Server_Config() |
6 changes: 3 additions & 3 deletions
6
...OSBot_Serverless_Flows__Shared_Objects.py → ...flows/Serverless_Flows__Shared_Objects.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
from osbot_serverless_flows.aws.s3.S3_DB__Flows import S3_DB__Flows | ||
from osbot_utils.base_classes.Type_Safe import Type_Safe | ||
from osbot_utils.base_classes.Type_Safe import Type_Safe | ||
|
||
|
||
class OSBot_Serverless_Flows__Shared_Objects(Type_Safe): | ||
class Serverless_Flows__Shared_Objects(Type_Safe): | ||
|
||
def s3_db_flows(self): | ||
s3_db_flows = S3_DB__Flows() | ||
s3_db_flows.setup() # will create buckey if needed | ||
return s3_db_flows | ||
|
||
osbot_serverless_flows__shared_objects = OSBot_Serverless_Flows__Shared_Objects() | ||
serverless_flows__shared_objects = Serverless_Flows__Shared_Objects() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,10 @@ | ||
from fastapi import FastAPI | ||
from mangum import Mangum | ||
|
||
from mangum import Mangum | ||
from osbot_serverless_flows.fast_api.Fast_API__Serverless_Flows import Fast_API__Serverless_Flows | ||
from osbot_serverless_flows.utils.Version import version__osbot_serverless_flows | ||
|
||
# app = FastAPI() | ||
# | ||
# @app.get("/") | ||
# def root(): | ||
# return {"message": "Hello World!"} | ||
# | ||
# @app.get("/ping") | ||
# def ping(): | ||
# return {"pong": "42"} | ||
# | ||
# @app.get("/version") | ||
# def version(): | ||
# return version__osbot_serverless_flows | ||
|
||
|
||
serverless_flows = Fast_API__Serverless_Flows().setup() | ||
app = serverless_flows.app() | ||
run = Mangum(app) | ||
|
||
if __name__ == "__main__": | ||
import uvicorn | ||
|
||
uvicorn.run(app, host="0.0.0.0", port=8080) |
14 changes: 0 additions & 14 deletions
14
osbot_serverless_flows/utils/OSBot_Serverless_Flows__Local_Stack.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
from unittest import TestCase | ||
|
||
from tests.integration.fast_api_objs_for_tests import osbot_serverless__flows_local_stack, DEFAULT_TEST__AWS_ACCOUNT_ID | ||
from osbot_serverless_flows.utils.OSBot_Serverless_Flows__Shared_Objects import osbot_serverless_flows__shared_objects | ||
from unittest import TestCase | ||
|
||
from osbot_utils.utils.Dev import pprint | ||
|
||
from osbot_local_stack.testing.TestCase__Local_Stack import TestCase__Local_Stack | ||
from osbot_serverless_flows.aws.s3.S3_DB__Flows import S3_DB__Flows | ||
from tests.integration.fast_api_objs_for_tests import fast_api__local_stack | ||
from osbot_local_stack.local_stack.Local_Stack import Local_Stack | ||
from osbot_serverless_flows.Serverless_Flows__Server_Config import DEFAULT__SERVERLESS_FLOWS__AWS_ACCOUNT_ID | ||
from osbot_serverless_flows.Serverless_Flows__Shared_Objects import serverless_flows__shared_objects | ||
from osbot_serverless_flows.aws.s3.S3_DB__Flows import S3_DB__Flows | ||
|
||
|
||
class test_S3_DB__Flows(TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.local_stack = osbot_serverless__flows_local_stack.local_stack | ||
cls.s3_db_flows = osbot_serverless_flows__shared_objects.s3_db_flows() | ||
cls.local_stack = fast_api__local_stack | ||
cls.s3_db_flows = serverless_flows__shared_objects.s3_db_flows() | ||
|
||
def test__setup_class(self): | ||
assert self.s3_db_flows.bucket_exists() is True | ||
assert self.s3_db_flows.s3_bucket () == f'osbot-serverless-flows-{DEFAULT_TEST__AWS_ACCOUNT_ID}-flows' | ||
assert type(self.local_stack) is Local_Stack | ||
assert type(self.s3_db_flows) == S3_DB__Flows | ||
assert self.local_stack.is_local_stack_configured_and_available() is True | ||
assert self.s3_db_flows.bucket_exists() is True | ||
assert self.s3_db_flows.s3_bucket () == f'serverless-flows-{DEFAULT__SERVERLESS_FLOWS__AWS_ACCOUNT_ID}-flows' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from unittest import TestCase | ||
|
||
from osbot_serverless_flows.Serverless_Flows__Server_Config import serverless_flows__server_config, \ | ||
DEFAULT__SERVERLESS_FLOWS__AWS_ACCOUNT_ID, ENV_NAME__SERVERLESS_FLOWS__USE_LOCAL_STACK | ||
from osbot_utils.testing.Temp_Env_Vars import Temp_Env_Vars | ||
from osbot_utils.utils.Objects import __ | ||
|
||
|
||
class test_OSBot_Serverless_Flows__Server_Config(TestCase): | ||
|
||
def test_setup(self): | ||
original_values = serverless_flows__server_config.obj() | ||
|
||
def reset_values(): | ||
serverless_flows__server_config.reset() | ||
assert serverless_flows__server_config.obj() == __(aws_account_id=DEFAULT__SERVERLESS_FLOWS__AWS_ACCOUNT_ID, use_local_stack=False) | ||
serverless_flows__server_config.setup() | ||
assert serverless_flows__server_config.obj() == original_values | ||
|
||
with Temp_Env_Vars(env_vars={'AWS_ACCOUNT_ID': '1234567890'}): | ||
assert serverless_flows__server_config.setup().aws_account_id == '1234567890' | ||
reset_values() | ||
|
||
with Temp_Env_Vars(env_vars={ENV_NAME__SERVERLESS_FLOWS__USE_LOCAL_STACK: 'True'}): | ||
assert serverless_flows__server_config.setup().use_local_stack == True | ||
reset_values() | ||
|
||
with Temp_Env_Vars(env_vars={ENV_NAME__SERVERLESS_FLOWS__USE_LOCAL_STACK: 'False'}): | ||
assert serverless_flows__server_config.setup().use_local_stack == original_values.use_local_stack | ||
reset_values() |
13 changes: 13 additions & 0 deletions
13
tests/integration/test_Serverless_Flows__Shared_Objects.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from unittest import TestCase | ||
from integration.fast_api_objs_for_tests import fast_api__local_stack | ||
from osbot_serverless_flows.Serverless_Flows__Server_Config import DEFAULT__SERVERLESS_FLOWS__AWS_ACCOUNT_ID | ||
from osbot_serverless_flows.Serverless_Flows__Shared_Objects import serverless_flows__shared_objects | ||
|
||
class test_Serverless_Flows__Shared_Objects(TestCase): | ||
|
||
def test_s3_db_flows(self): | ||
assert fast_api__local_stack.is_local_stack_configured_and_available() is True | ||
s3_db_flows = serverless_flows__shared_objects.s3_db_flows() | ||
|
||
assert s3_db_flows.s3_bucket() == F'serverless-flows-{DEFAULT__SERVERLESS_FLOWS__AWS_ACCOUNT_ID}-flows' | ||
assert s3_db_flows.bucket_exists() is True |
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
tests/integration/utils/test_OSBot_Serverless_Flows__Shared_Objects.py
This file was deleted.
Oops, something went wrong.