amsdal 0.1.26__cp311-cp311-win_amd64.whl → 0.2.0__cp311-cp311-win_amd64.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 amsdal might be problematic. Click here for more details.
- amsdal/__about__.py +1 -1
- amsdal/cloud/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/client.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/client.pyi +46 -2
- amsdal/cloud/constants.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/enums.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/enums.pyi +46 -0
- amsdal/cloud/models/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/models/base.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/models/base.pyi +156 -0
- amsdal/cloud/services/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.pyi +16 -1
- amsdal/cloud/services/actions/add_basic_auth.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_basic_auth.pyi +17 -1
- amsdal/cloud/services/actions/add_dependency.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_dependency.pyi +16 -1
- amsdal/cloud/services/actions/add_secret.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/add_secret.pyi +17 -1
- amsdal/cloud/services/actions/base.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/base.pyi +71 -3
- amsdal/cloud/services/actions/create_deploy.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/create_deploy.pyi +33 -3
- amsdal/cloud/services/actions/create_env.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/create_env.pyi +15 -1
- amsdal/cloud/services/actions/create_session.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/create_session.pyi +13 -1
- amsdal/cloud/services/actions/delete_allowlist_ip.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.pyi +16 -1
- amsdal/cloud/services/actions/delete_basic_auth.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_basic_auth.pyi +17 -1
- amsdal/cloud/services/actions/delete_dependency.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_dependency.pyi +18 -1
- amsdal/cloud/services/actions/delete_env.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_env.pyi +17 -1
- amsdal/cloud/services/actions/delete_secret.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/delete_secret.pyi +18 -1
- amsdal/cloud/services/actions/destroy_deploy.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/destroy_deploy.pyi +15 -1
- amsdal/cloud/services/actions/expose_db.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/expose_db.pyi +18 -1
- amsdal/cloud/services/actions/get_basic_auth_credentials.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +17 -1
- amsdal/cloud/services/actions/get_monitoring_info.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/get_monitoring_info.pyi +17 -1
- amsdal/cloud/services/actions/list_dependencies.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_dependencies.pyi +17 -1
- amsdal/cloud/services/actions/list_deploys.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_deploys.pyi +15 -1
- amsdal/cloud/services/actions/list_envs.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_envs.pyi +16 -1
- amsdal/cloud/services/actions/list_secrets.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/list_secrets.pyi +18 -1
- amsdal/cloud/services/actions/manager.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/manager.pyi +254 -20
- amsdal/cloud/services/actions/signup_action.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/signup_action.pyi +16 -1
- amsdal/cloud/services/actions/update_deploy.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/actions/update_deploy.pyi +15 -1
- amsdal/cloud/services/auth/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/base.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/credentials.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/credentials.pyi +12 -1
- amsdal/cloud/services/auth/manager.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/manager.pyi +15 -1
- amsdal/cloud/services/auth/signup_service.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/signup_service.pyi +16 -1
- amsdal/cloud/services/auth/token.cp311-win_amd64.pyd +0 -0
- amsdal/cloud/services/auth/token.pyi +15 -1
- amsdal/configs/constants.py +10 -0
- amsdal/configs/constants.pyi +11 -1
- amsdal/configs/main.py +132 -19
- amsdal/configs/main.pyi +140 -10
- amsdal/context/manager.py +39 -0
- amsdal/context/manager.pyi +41 -3
- amsdal/contrib/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/contrib/auth/app.py +12 -0
- amsdal/contrib/auth/app.pyi +12 -1
- amsdal/contrib/auth/lifecycle/consumer.py +53 -0
- amsdal/contrib/auth/lifecycle/consumer.pyi +53 -3
- amsdal/contrib/auth/models/login_session/hooks/pre_init.py +13 -0
- amsdal/contrib/auth/models/login_session/modifiers/display_name.py +8 -0
- amsdal/contrib/auth/models/permission/modifiers/display_name.py +8 -0
- amsdal/contrib/auth/models/user/hooks/post_init.py +13 -0
- amsdal/contrib/auth/models/user/hooks/pre_create.py +6 -0
- amsdal/contrib/auth/models/user/modifiers/display_name.py +8 -0
- amsdal/contrib/auth/settings.py +15 -0
- amsdal/contrib/auth/settings.pyi +14 -0
- amsdal/contrib/frontend_configs/app.py +14 -0
- amsdal/contrib/frontend_configs/app.pyi +14 -1
- amsdal/contrib/frontend_configs/conversion/convert.py +14 -0
- amsdal/contrib/frontend_configs/conversion/convert.pyi +15 -1
- amsdal/contrib/frontend_configs/lifecycle/consumer.py +75 -3
- amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +77 -6
- amsdal/contrib/frontend_configs/models/frontent_config_control_action/properties/action_validate.py +16 -0
- amsdal/contrib/frontend_configs/utils.py +12 -1
- amsdal/contrib/frontend_configs/utils.pyi +12 -1
- amsdal/fixtures/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/fixtures/manager.cp311-win_amd64.pyd +0 -0
- amsdal/fixtures/manager.pyi +90 -8
- amsdal/manager.cp311-win_amd64.pyd +0 -0
- amsdal/manager.pyi +113 -25
- amsdal/migration/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/migration/base_migration_schemas.cp311-win_amd64.pyd +0 -0
- amsdal/migration/base_migration_schemas.pyi +84 -8
- amsdal/migration/data_classes.cp311-win_amd64.pyd +0 -0
- amsdal/migration/data_classes.pyi +104 -4
- amsdal/migration/executors/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/migration/executors/base.cp311-win_amd64.pyd +0 -0
- amsdal/migration/executors/base.pyi +75 -5
- amsdal/migration/executors/default_executor.cp311-win_amd64.pyd +0 -0
- amsdal/migration/executors/default_executor.pyi +82 -10
- amsdal/migration/executors/state_executor.cp311-win_amd64.pyd +0 -0
- amsdal/migration/executors/state_executor.pyi +69 -5
- amsdal/migration/file_migration_executor.cp311-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_executor.pyi +34 -2
- amsdal/migration/file_migration_generator.cp311-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_generator.pyi +102 -10
- amsdal/migration/file_migration_store.cp311-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_store.pyi +36 -8
- amsdal/migration/file_migration_writer.cp311-win_amd64.pyd +0 -0
- amsdal/migration/file_migration_writer.pyi +60 -5
- amsdal/migration/migrations.cp311-win_amd64.pyd +0 -0
- amsdal/migration/migrations.pyi +111 -6
- amsdal/migration/migrations_loader.cp311-win_amd64.pyd +0 -0
- amsdal/migration/migrations_loader.pyi +17 -2
- amsdal/migration/schemas_loaders.cp311-win_amd64.pyd +0 -0
- amsdal/migration/schemas_loaders.pyi +15 -2
- amsdal/migration/utils.cp311-win_amd64.pyd +0 -0
- amsdal/migration/utils.pyi +46 -6
- amsdal/mixins/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/mixins/build_mixin.cp311-win_amd64.pyd +0 -0
- amsdal/mixins/build_mixin.pyi +60 -8
- amsdal/mixins/class_versions_mixin.cp311-win_amd64.pyd +0 -0
- amsdal/mixins/class_versions_mixin.pyi +3 -7
- amsdal/schemas/core/class_object/properties/display_name.py +6 -0
- amsdal/schemas/core/file/hooks/pre_create.py +9 -0
- amsdal/schemas/core/file/hooks/pre_update.py +9 -0
- amsdal/schemas/core/file/properties/from_file.py +12 -0
- amsdal/schemas/core/file/properties/mimetype.py +8 -0
- amsdal/schemas/core/file/properties/to_file.py +12 -0
- amsdal/schemas/core/file/properties/validate_data.py +13 -0
- amsdal/schemas/manager.cp311-win_amd64.pyd +0 -0
- amsdal/schemas/manager.py +53 -2
- amsdal/schemas/manager.pyi +55 -5
- amsdal/services/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/services/transaction_execution.cp311-win_amd64.pyd +0 -0
- amsdal/services/transaction_execution.pyi +52 -3
- amsdal/utils/contrib_paths.py +10 -0
- amsdal/utils/contrib_paths.pyi +11 -1
- amsdal/utils/tests/helpers.py +5 -7
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/METADATA +4 -6
- amsdal-0.2.0.dist-info/RECORD +254 -0
- amsdal/operations/__init__.cp311-win_amd64.pyd +0 -0
- amsdal/operations/__init__.pyi +0 -0
- amsdal/operations/manager.cp311-win_amd64.pyd +0 -0
- amsdal/operations/manager.pyi +0 -24
- amsdal-0.1.26.dist-info/RECORD +0 -258
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/LICENSE.txt +0 -0
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/WHEEL +0 -0
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/license_check.py +0 -0
- {amsdal-0.1.26.dist-info → amsdal-0.2.0.dist-info}/top_level.txt +0 -0
|
@@ -2,4 +2,19 @@ from amsdal.cloud.models.base import SignupReponseCredentials as SignupReponseCr
|
|
|
2
2
|
from amsdal.cloud.services.actions.base import CloudActionBase as CloudActionBase
|
|
3
3
|
|
|
4
4
|
class FreeSignupAction(CloudActionBase):
|
|
5
|
-
|
|
5
|
+
"""
|
|
6
|
+
Class to handle the free signup action.
|
|
7
|
+
|
|
8
|
+
This class provides functionality to sign up a client for free using the provided organization name and email.
|
|
9
|
+
"""
|
|
10
|
+
def action(self, organization_name: str, email: str) -> SignupReponseCredentials:
|
|
11
|
+
"""
|
|
12
|
+
Executes the free signup action with the given parameters.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
organization_name (str): The name of the organization.
|
|
16
|
+
email (str): The email address for signup.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
SignupReponseCredentials: The response containing the signup credentials.
|
|
20
|
+
"""
|
|
Binary file
|
|
@@ -2,4 +2,18 @@ from amsdal.cloud.models.base import UpdateDeployStatusResponse as UpdateDeployS
|
|
|
2
2
|
from amsdal.cloud.services.actions.base import CloudActionBase as CloudActionBase
|
|
3
3
|
|
|
4
4
|
class UpdateDeployAction(CloudActionBase):
|
|
5
|
-
|
|
5
|
+
"""
|
|
6
|
+
Class to handle the update of deployment status.
|
|
7
|
+
|
|
8
|
+
This class provides functionality to update the status of a deployment using the given deployment ID.
|
|
9
|
+
"""
|
|
10
|
+
def action(self, deployment_id: str) -> UpdateDeployStatusResponse:
|
|
11
|
+
"""
|
|
12
|
+
Updates the status of a deployment with the given deployment ID.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
deployment_id (str): The ID of the deployment to be updated.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
UpdateDeployStatusResponse: The response containing the updated deployment status.
|
|
19
|
+
"""
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -9,6 +9,11 @@ from amsdal.errors import AmsdalAuthenticationError as AmsdalAuthenticationError
|
|
|
9
9
|
from amsdal.schemas.manager import SchemaManager as SchemaManager
|
|
10
10
|
|
|
11
11
|
class CredentialsAuthHandler(AuthHandlerBase):
|
|
12
|
+
"""
|
|
13
|
+
Handles authentication using credentials.
|
|
14
|
+
|
|
15
|
+
This class provides functionality to authenticate using an access key ID and a secret access key.
|
|
16
|
+
"""
|
|
12
17
|
__access_key_id: Incomplete
|
|
13
18
|
__secret_access_key: Incomplete
|
|
14
19
|
__fernet: Incomplete
|
|
@@ -17,4 +22,10 @@ class CredentialsAuthHandler(AuthHandlerBase):
|
|
|
17
22
|
def _create_session(self) -> str: ...
|
|
18
23
|
def _get_public_key(self) -> str: ...
|
|
19
24
|
def _decode_public_key(self, key: str) -> str: ...
|
|
20
|
-
def validate_credentials(self) -> None:
|
|
25
|
+
def validate_credentials(self) -> None:
|
|
26
|
+
"""
|
|
27
|
+
Validates the provided credentials by creating a session and decoding the public key.
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
AmsdalAuthenticationError: If the credentials are invalid.
|
|
31
|
+
"""
|
|
Binary file
|
|
@@ -7,6 +7,20 @@ from amsdal.errors import AmsdalAuthenticationError as AmsdalAuthenticationError
|
|
|
7
7
|
from amsdal_utils.utils.singleton import Singleton
|
|
8
8
|
|
|
9
9
|
class AuthManager(metaclass=Singleton):
|
|
10
|
+
"""
|
|
11
|
+
Manages authentication for the application.
|
|
12
|
+
|
|
13
|
+
This class handles the initialization and validation of authentication credentials based on
|
|
14
|
+
the provided authentication type.
|
|
15
|
+
"""
|
|
10
16
|
_auth_handler: AuthHandlerBase
|
|
11
17
|
def __init__(self, auth_type: AuthType | None = None) -> None: ...
|
|
12
|
-
def authenticate(self) -> None:
|
|
18
|
+
def authenticate(self) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Authenticates the user by validating the provided credentials.
|
|
21
|
+
|
|
22
|
+
This method uses the authentication handler to validate the credentials based on the authentication type.
|
|
23
|
+
|
|
24
|
+
Raises:
|
|
25
|
+
AmsdalAuthenticationError: If the authentication fails.
|
|
26
|
+
"""
|
|
Binary file
|
|
@@ -13,5 +13,20 @@ def organization_name_input() -> str: ...
|
|
|
13
13
|
def email_input() -> str: ...
|
|
14
14
|
|
|
15
15
|
class SignupService:
|
|
16
|
+
"""
|
|
17
|
+
Service to handle the signup process for the Amsdal Framework.
|
|
18
|
+
|
|
19
|
+
This class provides functionality to prompt the user for signup details, validate the license agreement,
|
|
20
|
+
and create credentials for the user.
|
|
21
|
+
"""
|
|
16
22
|
@classmethod
|
|
17
|
-
def signup_prompt(cls) -> bool:
|
|
23
|
+
def signup_prompt(cls) -> bool:
|
|
24
|
+
"""
|
|
25
|
+
Prompts the user to sign up for the Amsdal Framework.
|
|
26
|
+
|
|
27
|
+
This method guides the user through the signup process, including accepting the license agreement and
|
|
28
|
+
entering organization and email details. It then creates credentials for the user.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
bool: True if the signup process is completed successfully, False otherwise.
|
|
32
|
+
"""
|
|
Binary file
|
|
@@ -7,8 +7,22 @@ from amsdal.schemas.manager import SchemaManager as SchemaManager
|
|
|
7
7
|
HMAC_KEY: bytes
|
|
8
8
|
|
|
9
9
|
class TokenAuthHandler(AuthHandlerBase):
|
|
10
|
+
"""
|
|
11
|
+
Handles authentication using a token.
|
|
12
|
+
|
|
13
|
+
This class provides functionality to authenticate using a JWT token and validate its checksum.
|
|
14
|
+
"""
|
|
10
15
|
__token: Incomplete
|
|
11
16
|
public_key: Incomplete
|
|
12
17
|
def __init__(self, token: str | None, public_key: str = ...) -> None: ...
|
|
13
18
|
def _validate_checksum(self, expected_checksum: str) -> None: ...
|
|
14
|
-
def validate_credentials(self) -> None:
|
|
19
|
+
def validate_credentials(self) -> None:
|
|
20
|
+
"""
|
|
21
|
+
Validates the provided JWT token.
|
|
22
|
+
|
|
23
|
+
This method decodes the token and validates its checksum or expiration date.
|
|
24
|
+
|
|
25
|
+
Raises:
|
|
26
|
+
AmsdalAuthenticationError: If the token is expired, has an invalid signature, is invalid, or is missing
|
|
27
|
+
an expiration date.
|
|
28
|
+
"""
|
amsdal/configs/constants.py
CHANGED
|
@@ -15,6 +15,16 @@ PRODUCTION_ENVIRONMENT = 'production'
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def get_default_environment() -> str:
|
|
18
|
+
"""
|
|
19
|
+
Determines the default environment based on the command used to run the script.
|
|
20
|
+
|
|
21
|
+
This function checks the command used to run the script and returns the appropriate
|
|
22
|
+
environment string. If the script is run using `pytest`, it returns 'testing'. Otherwise,
|
|
23
|
+
it returns 'development'.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
str: The default environment string, either 'testing' or 'development'.
|
|
27
|
+
"""
|
|
18
28
|
cmd = sys.argv[0] if sys.argv else ''
|
|
19
29
|
|
|
20
30
|
if 'pytest' in cmd:
|
amsdal/configs/constants.pyi
CHANGED
|
@@ -9,4 +9,14 @@ TESTING_ENVIRONMENT: str
|
|
|
9
9
|
DEVELOPMENT_ENVIRONMENT: str
|
|
10
10
|
PRODUCTION_ENVIRONMENT: str
|
|
11
11
|
|
|
12
|
-
def get_default_environment() -> str:
|
|
12
|
+
def get_default_environment() -> str:
|
|
13
|
+
"""
|
|
14
|
+
Determines the default environment based on the command used to run the script.
|
|
15
|
+
|
|
16
|
+
This function checks the command used to run the script and returns the appropriate
|
|
17
|
+
environment string. If the script is run using `pytest`, it returns 'testing'. Otherwise,
|
|
18
|
+
it returns 'development'.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
str: The default environment string, either 'testing' or 'development'.
|
|
22
|
+
"""
|
amsdal/configs/main.py
CHANGED
|
@@ -11,6 +11,33 @@ from pydantic_settings import SettingsConfigDict
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class Settings(BaseSettings):
|
|
14
|
+
"""
|
|
15
|
+
Configuration settings for the application.
|
|
16
|
+
|
|
17
|
+
This class defines the configuration settings for the application, including paths,
|
|
18
|
+
environment variables, and other settings.
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
model_config (SettingsConfigDict): Configuration for the settings model.
|
|
22
|
+
APP_PATH (Path): Path to the app directory where the generated models and other files will be placed.
|
|
23
|
+
CONFIG_PATH (Path | None): Path to the config.yml file. If not specified, the default APP_PATH/config.yml
|
|
24
|
+
file will be used.
|
|
25
|
+
MODELS_MODULE_NAME (str): The models module name. The generated models will be placed in this module.
|
|
26
|
+
SCHEMAS_MODULE_NAME (str): The schemas module name. The schemas will be placed in this module.
|
|
27
|
+
FIXTURES_MODULE_NAME (str): The fixtures module name. The fixtures will be placed in this module.
|
|
28
|
+
STATIC_MODULE_NAME (str): The static module name. The static files will be placed in this module.
|
|
29
|
+
TRANSACTIONS_MODULE_NAME (str): The transactions module name. The transactions will be placed in this module.
|
|
30
|
+
MIGRATIONS_DIRECTORY_NAME (str): The migrations directory name. The migration files will be placed in this
|
|
31
|
+
folder.
|
|
32
|
+
ACCESS_KEY_ID (str | None): The access key that you will get during registering process.
|
|
33
|
+
SECRET_ACCESS_KEY (str | None): The secret access key that you will get during registering process.
|
|
34
|
+
ACCESS_TOKEN (str | None): The access token that you will get during sign in process.
|
|
35
|
+
SANDBOX_ENVIRONMENT (bool | None): If True, the sandbox environment will be used. If False,
|
|
36
|
+
the cloud environment will be used.
|
|
37
|
+
CONTRIBS (list[str]): List of contrib modules that will be loaded and used.
|
|
38
|
+
Can be specified via environment variable AMSDAL_CONTRIBS as comma separated string.
|
|
39
|
+
"""
|
|
40
|
+
|
|
14
41
|
model_config = SettingsConfigDict(
|
|
15
42
|
case_sensitive=True,
|
|
16
43
|
env_prefix='AMSDAL_',
|
|
@@ -20,43 +47,36 @@ class Settings(BaseSettings):
|
|
|
20
47
|
)
|
|
21
48
|
|
|
22
49
|
APP_PATH: Path = Path('.')
|
|
23
|
-
"""Path to the app directory where the generated models and other files will be placed."""
|
|
24
|
-
|
|
25
50
|
CONFIG_PATH: Path | None = None
|
|
26
|
-
"""Path to the config.yml file. If not specified, the default APP_PATH/config.yml file will be used."""
|
|
27
|
-
|
|
28
51
|
MODELS_MODULE_NAME: str = 'models'
|
|
29
|
-
"""The models module name. The generated models will be placed in this module."""
|
|
30
52
|
SCHEMAS_MODULE_NAME: str = 'schemas'
|
|
31
|
-
"""The schemas module name. The schemas will be placed in this module."""
|
|
32
53
|
FIXTURES_MODULE_NAME: str = 'fixtures'
|
|
33
|
-
"""The fixtures module name. The fixtures will be placed in this module."""
|
|
34
54
|
STATIC_MODULE_NAME: str = 'static'
|
|
35
|
-
"""The static module name. The static files will be placed in this module."""
|
|
36
55
|
TRANSACTIONS_MODULE_NAME: str = 'transactions'
|
|
37
|
-
"""The transactions module name. The transactions will be placed in this module."""
|
|
38
56
|
MIGRATIONS_DIRECTORY_NAME: str = 'migrations'
|
|
39
|
-
"""The migrations directory name. The migration files will be placed in this folder."""
|
|
40
|
-
|
|
41
57
|
ACCESS_KEY_ID: str | None = None
|
|
42
|
-
"""The access key that you will get during registering process."""
|
|
43
58
|
SECRET_ACCESS_KEY: str | None = None
|
|
44
|
-
"""The secret access key that you will get during registering process."""
|
|
45
59
|
ACCESS_TOKEN: str | None = None
|
|
46
|
-
"""The access token that you will get during sign in process."""
|
|
47
|
-
|
|
48
60
|
SANDBOX_ENVIRONMENT: bool | None = None
|
|
49
|
-
"""If True, the sandbox environment will be used. If False, the cloud environment will be used."""
|
|
50
|
-
|
|
51
61
|
CONTRIBS: list[str] = [
|
|
52
62
|
'amsdal.contrib.auth.app.AuthAppConfig',
|
|
53
63
|
'amsdal.contrib.frontend_configs.app.FrontendConfigAppConfig',
|
|
54
64
|
]
|
|
55
|
-
"""List of contrib modules that will be loaded and used. Can be specified via environment variable AMSDAL_CONTRIBS
|
|
56
|
-
as comma separated string."""
|
|
57
65
|
|
|
58
66
|
@field_validator('CONTRIBS', mode='after')
|
|
59
67
|
def load_contrib_modules(cls, value: list[str]) -> list[str]: # noqa: N805
|
|
68
|
+
"""
|
|
69
|
+
Loads and initializes contrib modules.
|
|
70
|
+
|
|
71
|
+
This method takes a list of contrib module paths, imports each module, and calls the `on_ready` method
|
|
72
|
+
of the `AppConfig` class within each module.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
value (list[str]): A list of contrib module paths in the format 'package.module.ClassName'.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
list[str]: The same list of contrib module paths after loading and initializing the modules.
|
|
79
|
+
"""
|
|
60
80
|
from amsdal.contrib.app_config import AppConfig
|
|
61
81
|
|
|
62
82
|
for contrib_module in value:
|
|
@@ -69,30 +89,93 @@ class Settings(BaseSettings):
|
|
|
69
89
|
|
|
70
90
|
@property
|
|
71
91
|
def models_root_path(self) -> Path:
|
|
92
|
+
"""
|
|
93
|
+
Returns the root path for models.
|
|
94
|
+
|
|
95
|
+
This property constructs and returns the path to the models directory
|
|
96
|
+
based on the `APP_PATH` and `MODELS_MODULE_NAME` attributes.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
Path: The root path for the models directory.
|
|
100
|
+
"""
|
|
72
101
|
return self.APP_PATH / self.MODELS_MODULE_NAME
|
|
73
102
|
|
|
74
103
|
@property
|
|
75
104
|
def schemas_root_path(self) -> Path:
|
|
105
|
+
"""
|
|
106
|
+
Returns the root path for schemas.
|
|
107
|
+
|
|
108
|
+
This property constructs and returns the path to the schemas directory
|
|
109
|
+
based on the `APP_PATH` and `SCHEMAS_MODULE_NAME` attributes.
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
Path: The root path for the schemas directory.
|
|
113
|
+
"""
|
|
76
114
|
return self.APP_PATH / self.SCHEMAS_MODULE_NAME
|
|
77
115
|
|
|
78
116
|
@property
|
|
79
117
|
def fixtures_root_path(self) -> Path:
|
|
118
|
+
"""
|
|
119
|
+
Returns the root path for fixtures.
|
|
120
|
+
|
|
121
|
+
This property constructs and returns the path to the fixtures directory
|
|
122
|
+
based on the `APP_PATH` and `FIXTURES_MODULE_NAME` attributes.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
Path: The root path for the fixtures directory.
|
|
126
|
+
"""
|
|
80
127
|
return self.APP_PATH / self.FIXTURES_MODULE_NAME
|
|
81
128
|
|
|
82
129
|
@property
|
|
83
130
|
def static_root_path(self) -> Path:
|
|
131
|
+
"""
|
|
132
|
+
Returns the root path for static files.
|
|
133
|
+
|
|
134
|
+
This property constructs and returns the path to the static files directory
|
|
135
|
+
based on the `APP_PATH` and `STATIC_MODULE_NAME` attributes.
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
Path: The root path for the static files directory.
|
|
139
|
+
"""
|
|
84
140
|
return self.APP_PATH / self.STATIC_MODULE_NAME
|
|
85
141
|
|
|
86
142
|
@property
|
|
87
143
|
def transactions_root_path(self) -> Path:
|
|
144
|
+
"""
|
|
145
|
+
Returns the root path for transactions.
|
|
146
|
+
|
|
147
|
+
This property constructs and returns the path to the transactions directory
|
|
148
|
+
based on the `models_root_path` and `TRANSACTIONS_MODULE_NAME` attributes.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
Path: The root path for the transactions directory.
|
|
152
|
+
"""
|
|
88
153
|
return self.models_root_path / self.TRANSACTIONS_MODULE_NAME
|
|
89
154
|
|
|
90
155
|
@property
|
|
91
156
|
def migrations_root_path(self) -> Path:
|
|
157
|
+
"""
|
|
158
|
+
Returns the root path for migrations.
|
|
159
|
+
|
|
160
|
+
This property constructs and returns the path to the migrations directory
|
|
161
|
+
based on the `models_root_path` and `MIGRATIONS_DIRECTORY_NAME` attributes.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
Path: The root path for the migrations directory.
|
|
165
|
+
"""
|
|
92
166
|
return self.models_root_path / self.MIGRATIONS_DIRECTORY_NAME
|
|
93
167
|
|
|
94
168
|
@model_validator(mode='after')
|
|
95
169
|
def check_passwords_match(self) -> 'Settings':
|
|
170
|
+
"""
|
|
171
|
+
Ensures the configuration path is set.
|
|
172
|
+
|
|
173
|
+
This method checks if the `CONFIG_PATH` attribute is set. If it is not set,
|
|
174
|
+
it assigns a default path based on the `APP_PATH` attribute.
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
Settings: The updated settings instance with the `CONFIG_PATH` attribute set.
|
|
178
|
+
"""
|
|
96
179
|
config_path = self.CONFIG_PATH
|
|
97
180
|
|
|
98
181
|
if not config_path:
|
|
@@ -108,15 +191,45 @@ else:
|
|
|
108
191
|
|
|
109
192
|
|
|
110
193
|
class SettingsProxy(base):
|
|
194
|
+
"""
|
|
195
|
+
Proxy class for accessing and modifying settings.
|
|
196
|
+
|
|
197
|
+
This class acts as a proxy for the `Settings` class, allowing for dynamic
|
|
198
|
+
overriding and accessing of settings attributes.
|
|
199
|
+
"""
|
|
200
|
+
|
|
111
201
|
def __init__(self) -> None:
|
|
112
202
|
self._settings = Settings()
|
|
113
203
|
|
|
114
204
|
def override(self, **kwargs: Any) -> None:
|
|
205
|
+
"""
|
|
206
|
+
Overrides settings with provided keyword arguments.
|
|
207
|
+
|
|
208
|
+
This method updates the current settings with the provided keyword arguments.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
**kwargs: Keyword arguments representing settings to override.
|
|
212
|
+
|
|
213
|
+
Returns:
|
|
214
|
+
None
|
|
215
|
+
"""
|
|
115
216
|
new_settings = self._settings.model_dump()
|
|
116
217
|
new_settings.update(kwargs)
|
|
117
218
|
self._settings = Settings(**new_settings)
|
|
118
219
|
|
|
119
220
|
def model_dump(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
|
|
221
|
+
"""
|
|
222
|
+
Dumps the current settings model to a dictionary.
|
|
223
|
+
|
|
224
|
+
This method returns the current settings as a dictionary.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
*args: Additional positional arguments to pass to the underlying model dump method.
|
|
228
|
+
**kwargs: Additional keyword arguments to pass to the underlying model dump method.
|
|
229
|
+
|
|
230
|
+
Returns:
|
|
231
|
+
dict[str, Any]: The current settings as a dictionary.
|
|
232
|
+
"""
|
|
120
233
|
return self._settings.model_dump(*args, **kwargs)
|
|
121
234
|
|
|
122
235
|
def __getattr__(self, name: str) -> Any:
|
amsdal/configs/main.pyi
CHANGED
|
@@ -4,6 +4,32 @@ from pydantic_settings import BaseSettings
|
|
|
4
4
|
from typing import Any, TypeAlias
|
|
5
5
|
|
|
6
6
|
class Settings(BaseSettings):
|
|
7
|
+
"""
|
|
8
|
+
Configuration settings for the application.
|
|
9
|
+
|
|
10
|
+
This class defines the configuration settings for the application, including paths,
|
|
11
|
+
environment variables, and other settings.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
model_config (SettingsConfigDict): Configuration for the settings model.
|
|
15
|
+
APP_PATH (Path): Path to the app directory where the generated models and other files will be placed.
|
|
16
|
+
CONFIG_PATH (Path | None): Path to the config.yml file. If not specified, the default APP_PATH/config.yml
|
|
17
|
+
file will be used.
|
|
18
|
+
MODELS_MODULE_NAME (str): The models module name. The generated models will be placed in this module.
|
|
19
|
+
SCHEMAS_MODULE_NAME (str): The schemas module name. The schemas will be placed in this module.
|
|
20
|
+
FIXTURES_MODULE_NAME (str): The fixtures module name. The fixtures will be placed in this module.
|
|
21
|
+
STATIC_MODULE_NAME (str): The static module name. The static files will be placed in this module.
|
|
22
|
+
TRANSACTIONS_MODULE_NAME (str): The transactions module name. The transactions will be placed in this module.
|
|
23
|
+
MIGRATIONS_DIRECTORY_NAME (str): The migrations directory name. The migration files will be placed in this
|
|
24
|
+
folder.
|
|
25
|
+
ACCESS_KEY_ID (str | None): The access key that you will get during registering process.
|
|
26
|
+
SECRET_ACCESS_KEY (str | None): The secret access key that you will get during registering process.
|
|
27
|
+
ACCESS_TOKEN (str | None): The access token that you will get during sign in process.
|
|
28
|
+
SANDBOX_ENVIRONMENT (bool | None): If True, the sandbox environment will be used. If False,
|
|
29
|
+
the cloud environment will be used.
|
|
30
|
+
CONTRIBS (list[str]): List of contrib modules that will be loaded and used.
|
|
31
|
+
Can be specified via environment variable AMSDAL_CONTRIBS as comma separated string.
|
|
32
|
+
"""
|
|
7
33
|
model_config: Incomplete
|
|
8
34
|
APP_PATH: Path
|
|
9
35
|
CONFIG_PATH: Path | None
|
|
@@ -18,28 +44,132 @@ class Settings(BaseSettings):
|
|
|
18
44
|
ACCESS_TOKEN: str | None
|
|
19
45
|
SANDBOX_ENVIRONMENT: bool | None
|
|
20
46
|
CONTRIBS: list[str]
|
|
21
|
-
def load_contrib_modules(cls, value: list[str]) -> list[str]:
|
|
47
|
+
def load_contrib_modules(cls, value: list[str]) -> list[str]:
|
|
48
|
+
"""
|
|
49
|
+
Loads and initializes contrib modules.
|
|
50
|
+
|
|
51
|
+
This method takes a list of contrib module paths, imports each module, and calls the `on_ready` method
|
|
52
|
+
of the `AppConfig` class within each module.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
value (list[str]): A list of contrib module paths in the format 'package.module.ClassName'.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
list[str]: The same list of contrib module paths after loading and initializing the modules.
|
|
59
|
+
"""
|
|
22
60
|
@property
|
|
23
|
-
def models_root_path(self) -> Path:
|
|
61
|
+
def models_root_path(self) -> Path:
|
|
62
|
+
"""
|
|
63
|
+
Returns the root path for models.
|
|
64
|
+
|
|
65
|
+
This property constructs and returns the path to the models directory
|
|
66
|
+
based on the `APP_PATH` and `MODELS_MODULE_NAME` attributes.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
Path: The root path for the models directory.
|
|
70
|
+
"""
|
|
24
71
|
@property
|
|
25
|
-
def schemas_root_path(self) -> Path:
|
|
72
|
+
def schemas_root_path(self) -> Path:
|
|
73
|
+
"""
|
|
74
|
+
Returns the root path for schemas.
|
|
75
|
+
|
|
76
|
+
This property constructs and returns the path to the schemas directory
|
|
77
|
+
based on the `APP_PATH` and `SCHEMAS_MODULE_NAME` attributes.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Path: The root path for the schemas directory.
|
|
81
|
+
"""
|
|
26
82
|
@property
|
|
27
|
-
def fixtures_root_path(self) -> Path:
|
|
83
|
+
def fixtures_root_path(self) -> Path:
|
|
84
|
+
"""
|
|
85
|
+
Returns the root path for fixtures.
|
|
86
|
+
|
|
87
|
+
This property constructs and returns the path to the fixtures directory
|
|
88
|
+
based on the `APP_PATH` and `FIXTURES_MODULE_NAME` attributes.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
Path: The root path for the fixtures directory.
|
|
92
|
+
"""
|
|
28
93
|
@property
|
|
29
|
-
def static_root_path(self) -> Path:
|
|
94
|
+
def static_root_path(self) -> Path:
|
|
95
|
+
"""
|
|
96
|
+
Returns the root path for static files.
|
|
97
|
+
|
|
98
|
+
This property constructs and returns the path to the static files directory
|
|
99
|
+
based on the `APP_PATH` and `STATIC_MODULE_NAME` attributes.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
Path: The root path for the static files directory.
|
|
103
|
+
"""
|
|
30
104
|
@property
|
|
31
|
-
def transactions_root_path(self) -> Path:
|
|
105
|
+
def transactions_root_path(self) -> Path:
|
|
106
|
+
"""
|
|
107
|
+
Returns the root path for transactions.
|
|
108
|
+
|
|
109
|
+
This property constructs and returns the path to the transactions directory
|
|
110
|
+
based on the `models_root_path` and `TRANSACTIONS_MODULE_NAME` attributes.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
Path: The root path for the transactions directory.
|
|
114
|
+
"""
|
|
32
115
|
@property
|
|
33
|
-
def migrations_root_path(self) -> Path:
|
|
34
|
-
|
|
116
|
+
def migrations_root_path(self) -> Path:
|
|
117
|
+
"""
|
|
118
|
+
Returns the root path for migrations.
|
|
119
|
+
|
|
120
|
+
This property constructs and returns the path to the migrations directory
|
|
121
|
+
based on the `models_root_path` and `MIGRATIONS_DIRECTORY_NAME` attributes.
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
Path: The root path for the migrations directory.
|
|
125
|
+
"""
|
|
126
|
+
def check_passwords_match(self) -> Settings:
|
|
127
|
+
"""
|
|
128
|
+
Ensures the configuration path is set.
|
|
129
|
+
|
|
130
|
+
This method checks if the `CONFIG_PATH` attribute is set. If it is not set,
|
|
131
|
+
it assigns a default path based on the `APP_PATH` attribute.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
Settings: The updated settings instance with the `CONFIG_PATH` attribute set.
|
|
135
|
+
"""
|
|
35
136
|
|
|
36
137
|
base: TypeAlias
|
|
37
138
|
|
|
38
139
|
class SettingsProxy(base):
|
|
140
|
+
"""
|
|
141
|
+
Proxy class for accessing and modifying settings.
|
|
142
|
+
|
|
143
|
+
This class acts as a proxy for the `Settings` class, allowing for dynamic
|
|
144
|
+
overriding and accessing of settings attributes.
|
|
145
|
+
"""
|
|
39
146
|
_settings: Incomplete
|
|
40
147
|
def __init__(self) -> None: ...
|
|
41
|
-
def override(self, **kwargs: Any) -> None:
|
|
42
|
-
|
|
148
|
+
def override(self, **kwargs: Any) -> None:
|
|
149
|
+
"""
|
|
150
|
+
Overrides settings with provided keyword arguments.
|
|
151
|
+
|
|
152
|
+
This method updates the current settings with the provided keyword arguments.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
**kwargs: Keyword arguments representing settings to override.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
None
|
|
159
|
+
"""
|
|
160
|
+
def model_dump(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
|
|
161
|
+
"""
|
|
162
|
+
Dumps the current settings model to a dictionary.
|
|
163
|
+
|
|
164
|
+
This method returns the current settings as a dictionary.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
*args: Additional positional arguments to pass to the underlying model dump method.
|
|
168
|
+
**kwargs: Additional keyword arguments to pass to the underlying model dump method.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
dict[str, Any]: The current settings as a dictionary.
|
|
172
|
+
"""
|
|
43
173
|
def __getattr__(self, name: str) -> Any: ...
|
|
44
174
|
def __delattr__(self, name: str) -> None: ...
|
|
45
175
|
def __setattr__(self, name: str, value: Any) -> None: ...
|
amsdal/context/manager.py
CHANGED
|
@@ -5,8 +5,24 @@ _CONTEXT: ContextVar[dict[str, Any] | None] = ContextVar('_context', default=Non
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class AmsdalContextManager:
|
|
8
|
+
"""
|
|
9
|
+
Manages a context for storing and retrieving data.
|
|
10
|
+
|
|
11
|
+
This class provides methods to get, set, and add to a context stored in a
|
|
12
|
+
`ContextVar`. The context is a dictionary that can hold any key-value pairs.
|
|
13
|
+
"""
|
|
14
|
+
|
|
8
15
|
@classmethod
|
|
9
16
|
def get_context(cls) -> dict[str, Any]:
|
|
17
|
+
"""
|
|
18
|
+
Retrieves the current context or creates a new one if none exists.
|
|
19
|
+
|
|
20
|
+
This method gets the current context from the `_CONTEXT` variable. If no
|
|
21
|
+
context exists, it creates a new empty context and sets it.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
dict[str, Any]: The current context.
|
|
25
|
+
"""
|
|
10
26
|
_context = _CONTEXT.get()
|
|
11
27
|
|
|
12
28
|
if _context is not None:
|
|
@@ -19,10 +35,33 @@ class AmsdalContextManager:
|
|
|
19
35
|
|
|
20
36
|
@classmethod
|
|
21
37
|
def set_context(cls, context: dict[str, Any]) -> None:
|
|
38
|
+
"""
|
|
39
|
+
Sets the context to the provided dictionary.
|
|
40
|
+
|
|
41
|
+
This method sets the `_CONTEXT` variable to the provided context.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
context (dict[str, Any]): The context to set.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
None
|
|
48
|
+
"""
|
|
22
49
|
_CONTEXT.set(context)
|
|
23
50
|
|
|
24
51
|
@classmethod
|
|
25
52
|
def add_to_context(cls, key: str, value: Any) -> None:
|
|
53
|
+
"""
|
|
54
|
+
Adds a key-value pair to the current context.
|
|
55
|
+
|
|
56
|
+
This method adds the provided key-value pair to the current context.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
key (str): The key to add to the context.
|
|
60
|
+
value (Any): The value to associate with the key.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
None
|
|
64
|
+
"""
|
|
26
65
|
context = cls.get_context()
|
|
27
66
|
|
|
28
67
|
context[key] = value
|