Skip to main content

Python library designed to be a utility for OMS microservices

Project description

Saas MS Library

Saas MS Library is a Python library designed to be a utility for OMS microservices. This library provides an easy-to-use and highly customizable solution for reusing application utilities and clients, allowing developers to focus on creating the most efficient and scalable microservice.

With Saas MS Library, you will be able to handle AWS databases and clients. Our library is compatible with Python 3.10 and later versions, and is under constant development to improve its performance and extend its functionality.

Features

  1. Database Handler (MongoDB, Redis, PostgreSQL, etc.)
  2. AWS Client Handler (Cognito, S3, etc.)
  3. Decorators

Installation

To install saas-ms-library, simply run the following command:

pip install saas-ms-library

Examples of use

Here are some examples of how to use saas-ms-library in your projects:

Create environment variables

GRPC_PORT=50051
GRPC_MAX_WORKERS=10
SERVICE_ID=saas-ms-user
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_DB=0

Use

from protos.v1.users import user_pb2, user_pb2_grpc
from omni.pro.decorators import resources_decorator
from omni.pro.util import HTTPStatus, Resource, deep_search, nested


class  UserService(user_pb2_grpc.UsersServiceServicer):
    @resources_decorator([Resource.AWS_COGNITO, Resource.MONGODB])
    def  UserCreate(
        self, request: user_pb2.UserCreateRequest, context
        ) -> user_pb2.UserCreateResponse:
            response = context.cognito_client.create_user(
                username=data["username"],
                password=data["password"],
                name=data["name"],
                email=data["email"],
                tenant=data["tenant"],
                language_code=data["language"]["code"],
                timezone_code=data["timezone"]["code"],
            )
            att_list = nested(response, "User.Attributes") or  nested(response, "UserAttributes", default=[])
            sub_dict = deep_search(att_list, key, value)
            user = context.db_manager.get_document(
                context.db_name, UserDocument, sub=sub_dict.get("Value")
            )
            return  user_pb2.UserCreateResponse(
                response_standard=base_pb2.ResponseStandard(
                    success=True,
                    message="User created",
                    status_code=HTTPStatus.CREATED
                ),
                user=user.to_proto(),
            )

License

Saas MS Library is licensed under the modified MIT License.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

omni-pro-0.1.96.tar.gz (184.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omni_pro-0.1.96-py3-none-any.whl (409.1 kB view details)

Uploaded Python 3

File details

Details for the file omni-pro-0.1.96.tar.gz.

File metadata

  • Download URL: omni-pro-0.1.96.tar.gz
  • Upload date:
  • Size: 184.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for omni-pro-0.1.96.tar.gz
Algorithm Hash digest
SHA256 e92087d3db3b9fcc16d40526eedadafb25531ed1dec54a4bdd97f860457461a3
MD5 afb4f76e899431e2b53ed70982281ac2
BLAKE2b-256 40cba5de04c10c39735ceee9675be635ea2e8d3c9bade2d13e074fd916b13786

See more details on using hashes here.

File details

Details for the file omni_pro-0.1.96-py3-none-any.whl.

File metadata

  • Download URL: omni_pro-0.1.96-py3-none-any.whl
  • Upload date:
  • Size: 409.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for omni_pro-0.1.96-py3-none-any.whl
Algorithm Hash digest
SHA256 4f89fb4a8cefd75fd7e4dd62c1a30efc27ad7b55f4b90fc0f96d2755a1a7a9ce
MD5 43299b1e775581a9e14aaa5d8ada9166
BLAKE2b-256 400e3bb183afde5c7e26ad0f9595a8df6df707a93b436397ca1651a9bdaa0cb3

See more details on using hashes here.

Supported by

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