Skip to main content

A collection of Python libraries for A360

Project description

a360-python-libraries

Python shared libraries for a360 applications

License

This software is proprietary and is intended solely for use by Aesthetics-360 Inc.. Unauthorized use, distribution, or modification of this software outside of Aesthetics-360 Inc. is strictly prohibited.

Add package into your project

poetry add a360-python-libraries

Usage

Role based access control

from fastapi import APIRouter, Depends

from a360_security.depends import require_role
from a360_security.enums import Role

router = APIRouter()

@router.get(
    ...,
    dependencies=[Depends(require_role(Role.ADMIN))]
)
def get() -> dict:
    ...

You can provide multiple roles to the require_role dependency, and they will be checked in OR fashion.

from fastapi import APIRouter, Depends

from a360_security.depends import require_role
from a360_security.enums import Role

router = APIRouter()

@router.get(
    ...,
    dependencies=[Depends(require_role(Role.ADMIN, Role.SERVICE))]
)
def get() -> dict:
    ...

User valid practice dependency

from fastapi import APIRouter, Depends

from a360_security.depends import valid_practice

router = APIRouter()

@router.get(
    ...,
    dependencies=[Depends(valid_practice())]
)
def get() -> dict:
    ...

User dependency

from fastapi import APIRouter, Depends

from a360_security.depends import require_user
from a360_security.dto import UserDTO

router = APIRouter()

@router.get(
    ...,
)
def get(user: UserDTO = Depends(require_user)) -> dict:
    ...

Client platform

from fastapi import APIRouter, Depends

from a360_security.depends import require_client_platform
from a360_security.enums import ClientPlatform

router = APIRouter()

@router.get(
    ...,
)
def get(client_platform: ClientPlatform = Depends(require_client_platform)) -> dict:
    ...

Internal services

from fastapi import APIRouter, Depends

from a360_services import get_dictionary_service
from a360_services.services import DictionaryService

router = APIRouter()

@router.get(
    ...,
)
def get(dict_service: DictionaryService = Depends(get_dictionary_service)) -> dict:
    medical_conditions = dict_service.get_medical_conditions()

Email notification

from fastapi import APIRouter, Depends

from a360_notification import get_mail_service
from a360_notification.services import AWSSesService

router = APIRouter()

@router.post(
    ...,
)
def create(mail_service: AWSSesService = Depends(get_mail_service)):
    mail_service.send_email(
        recipient_name='John Doe',
        recipient_address='john.doe@example.com',
        subject='Test email',
        html_content='<h1>Test email</h1>',
    )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

a360_python_libraries-0.9.6.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

a360_python_libraries-0.9.6-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file a360_python_libraries-0.9.6.tar.gz.

File metadata

  • Download URL: a360_python_libraries-0.9.6.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/6.5.0-1025-azure

File hashes

Hashes for a360_python_libraries-0.9.6.tar.gz
Algorithm Hash digest
SHA256 0fb81f163b00a1bb4ec6076c059c76319cb68bb98c4bc90b115d7ddf9e8702c0
MD5 850b5227f7d150b3da18eb818820a167
BLAKE2b-256 6935a6c9b5b3d8f6a09bd8973611cf93fb3bc8a1f510d91d119ea06036b31b51

See more details on using hashes here.

File details

Details for the file a360_python_libraries-0.9.6-py3-none-any.whl.

File metadata

File hashes

Hashes for a360_python_libraries-0.9.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6341b6d75f259548a8f8676f9a078f1c5c4a30954a8eadad7ba62f49a87ffb42
MD5 abad6347d4c7a54bb7e00d69479da1c6
BLAKE2b-256 dd52c31e65d4a696607b6cb96fe569b6b639f9e7f882fb70c3685a3308f69895

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page