m360-middleware


Namem360-middleware JSON
Version 0.0.8 PyPI version JSON
download
home_pagehttps://www.corsairm360.com/
SummaryM360 middleware library for Python Django and Flask
upload_time2023-03-14 15:21:59
maintainer
docs_urlNone
authorHazkiel Gabriel
requires_python>=3.6
licenseapache-2.0
keywords m360 m360api middleware django flask
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # m360.mw.python

---

The M360 Python Middleware is a dependency that gets consumed by a Python Web Server built using one of these frameworks [Django](https://www.djangoproject.com/) and [Flask](https://flask.palletsprojects.com/en/2.0.x/).

The middleware is developed using native Python and includes interfaces that facilitate using it with the above mentioned frameworks.

## Installation ##

---
```commandline
pip install m360-middleware
```


## Usage ##

---
### Django ###
In your settings.py file, include the middleware and its configuration:
```python
import os
# ...
MIDDLEWARE = [
   # ...
   # -------------------- M360 Middleware Setup --------------------
   'm360.frameworks.django.middleware.DjangoMiddleware',
   # ...
]
# ...
M360 = {
    "contract": os.path.join(os.path.dirname(__file__), "./contract.json"),
    "ip":  os.environ.get('APP_IP') or "127.0.0.1",
    "type": "django",
    "platform": "manual"
}
```
In your **views**, import and use the middleware:
```python
from django.http import JsonResponse

# the sdk is initialized using the middleware when Django starts
from m360 import sdk
M360 = sdk.instance()

def get_settings(request):
    return JsonResponse(M360.registry.get(), status=200, safe=False)
```

### Flask ###
In your settings.py file, include the middleware and its configuration:
```python
import os
# ...
app = Flask(__name__)

from m360.frameworks.flask.middleware import FlaskMiddleware
app.wsgi_app = FlaskMiddleware(app.wsgi_app, {
    "contract": os.path.join(os.path.dirname(__file__), "./contract.json"),
    "ip": os.environ.get('APP_IP') or "127.0.0.1",
    "type": "flask",
    "platform": "manual"
})
```
In your **views**, import and use the middleware:
```python
# the sdk is initialized using the middleware when Flask starts
import json
from m360 import sdk
M360 = sdk.instance()

@app.route('/m360/settings', methods=['GET', 'POST'])
def m360_settings():
    return json.dumps(M360.registry.get())
```

## Containerized Deployment ##

---

### Deploying on Docker ###

When deploying on Docker, please provide the extra options below.
Without these options, the handshake between the middleware and the gateway will fail, 
along with any maintenance operation that gets triggered from the console onto this microservice.

Replace the `platform:manual` with `platform:docker` and add the below.

Option | Data Type | Mandatory | Description
--- | --- | --- | ---
platform | String | YES | value equals 'docker'
network | String | YES | value equals the docker network attached to this docker service
service | String | YES | value equals the name of the docker service
containerIP | String | NO | value is the internal IP address of the docker container in the docker service

**Example**
```javascript
'platform': 'docker',
'platformOptions': {
    'network': 'mike',
    'service': 'service-express',
    'containerIP': '127.0.0.1'
}
```
### Deploying on Kubernetes ###

When deploying on Kubernetes, please provide the extra options below.
Without these options, the handshake between the middleware and the gateway will fail,
along with any maintenance operation that gets triggered from the console onto this microservice.

Replace the `platform:manual` with `platform:kubernetes` and add the below.

Option | Data Type | Mandatory | Description
--- | --- | --- | ---
platform | String | YES | value equals 'kubernetes'
namespace | String | YES | value equals the kubernetes namespace where your deployment will run
service | String | YES | value equals the name of the kubernetes service that is attached to the your deployment
exposedPort | String | YES | value equals the exposed port kubernetes service

```javascript
'platform': 'kubernetes',
'platformOptions": {
    'namespace': 'mike',
    'service': 'service-express',
    'exposedPort': 30402
}
```

## Notes ##

---
The Middleware includes samples on how you can consume it with both Django and Flask.

These sample apps are located inside the **examples** folder in this repository.

Reference: [M360 Middleware Official Documentation](https://corsairm360.atlassian.net/servicedesk/customer/portal/4/topic/419cca91-5815-447b-abde-8455ae8a1717)

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.corsairm360.com/",
    "name": "m360-middleware",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "M360,M360API,Middleware,Django,Flask",
    "author": "Hazkiel Gabriel",
    "author_email": "hazkiel@corsairm360.com",
    "download_url": "https://files.pythonhosted.org/packages/d7/4b/afd38739db51fe4d8e9cc77dde1d064eddaf03ab91f71795043d5ab7744e/m360-middleware-0.0.8.tar.gz",
    "platform": null,
    "description": "# m360.mw.python\n\n---\n\nThe M360 Python Middleware is a dependency that gets consumed by a Python Web Server built using one of these frameworks [Django](https://www.djangoproject.com/) and [Flask](https://flask.palletsprojects.com/en/2.0.x/).\n\nThe middleware is developed using native Python and includes interfaces that facilitate using it with the above mentioned frameworks.\n\n## Installation ##\n\n---\n```commandline\npip install m360-middleware\n```\n\n\n## Usage ##\n\n---\n### Django ###\nIn your settings.py file, include the middleware and its configuration:\n```python\nimport os\n# ...\nMIDDLEWARE = [\n   # ...\n   # -------------------- M360 Middleware Setup --------------------\n   'm360.frameworks.django.middleware.DjangoMiddleware',\n   # ...\n]\n# ...\nM360 = {\n    \"contract\": os.path.join(os.path.dirname(__file__), \"./contract.json\"),\n    \"ip\":  os.environ.get('APP_IP') or \"127.0.0.1\",\n    \"type\": \"django\",\n    \"platform\": \"manual\"\n}\n```\nIn your **views**, import and use the middleware:\n```python\nfrom django.http import JsonResponse\n\n# the sdk is initialized using the middleware when Django starts\nfrom m360 import sdk\nM360 = sdk.instance()\n\ndef get_settings(request):\n    return JsonResponse(M360.registry.get(), status=200, safe=False)\n```\n\n### Flask ###\nIn your settings.py file, include the middleware and its configuration:\n```python\nimport os\n# ...\napp = Flask(__name__)\n\nfrom m360.frameworks.flask.middleware import FlaskMiddleware\napp.wsgi_app = FlaskMiddleware(app.wsgi_app, {\n    \"contract\": os.path.join(os.path.dirname(__file__), \"./contract.json\"),\n    \"ip\": os.environ.get('APP_IP') or \"127.0.0.1\",\n    \"type\": \"flask\",\n    \"platform\": \"manual\"\n})\n```\nIn your **views**, import and use the middleware:\n```python\n# the sdk is initialized using the middleware when Flask starts\nimport json\nfrom m360 import sdk\nM360 = sdk.instance()\n\n@app.route('/m360/settings', methods=['GET', 'POST'])\ndef m360_settings():\n    return json.dumps(M360.registry.get())\n```\n\n## Containerized Deployment ##\n\n---\n\n### Deploying on Docker ###\n\nWhen deploying on Docker, please provide the extra options below.\nWithout these options, the handshake between the middleware and the gateway will fail, \nalong with any maintenance operation that gets triggered from the console onto this microservice.\n\nReplace the `platform:manual` with `platform:docker` and add the below.\n\nOption | Data Type | Mandatory | Description\n--- | --- | --- | ---\nplatform | String | YES | value equals 'docker'\nnetwork | String | YES | value equals the docker network attached to this docker service\nservice | String | YES | value equals the name of the docker service\ncontainerIP | String | NO | value is the internal IP address of the docker container in the docker service\n\n**Example**\n```javascript\n'platform': 'docker',\n'platformOptions': {\n    'network': 'mike',\n    'service': 'service-express',\n    'containerIP': '127.0.0.1'\n}\n```\n### Deploying on Kubernetes ###\n\nWhen deploying on Kubernetes, please provide the extra options below.\nWithout these options, the handshake between the middleware and the gateway will fail,\nalong with any maintenance operation that gets triggered from the console onto this microservice.\n\nReplace the `platform:manual` with `platform:kubernetes` and add the below.\n\nOption | Data Type | Mandatory | Description\n--- | --- | --- | ---\nplatform | String | YES | value equals 'kubernetes'\nnamespace | String | YES | value equals the kubernetes namespace where your deployment will run\nservice | String | YES | value equals the name of the kubernetes service that is attached to the your deployment\nexposedPort | String | YES | value equals the exposed port kubernetes service\n\n```javascript\n'platform': 'kubernetes',\n'platformOptions\": {\n    'namespace': 'mike',\n    'service': 'service-express',\n    'exposedPort': 30402\n}\n```\n\n## Notes ##\n\n---\nThe Middleware includes samples on how you can consume it with both Django and Flask.\n\nThese sample apps are located inside the **examples** folder in this repository.\n\nReference: [M360 Middleware Official Documentation](https://corsairm360.atlassian.net/servicedesk/customer/portal/4/topic/419cca91-5815-447b-abde-8455ae8a1717)\n",
    "bugtrack_url": null,
    "license": "apache-2.0",
    "summary": "M360 middleware library for Python Django and Flask",
    "version": "0.0.8",
    "split_keywords": [
        "m360",
        "m360api",
        "middleware",
        "django",
        "flask"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05d86ebd1a1a28aa70fa9650cc34559cf97ea2d888d109ed2cb56d53e612f315",
                "md5": "19ac7859c29c6d07288d6e4d6be328b5",
                "sha256": "fd9c16b6085f2b5a6c5ecef069111dc591751736b78fb9b206669274483f3556"
            },
            "downloads": -1,
            "filename": "m360_middleware-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "19ac7859c29c6d07288d6e4d6be328b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 51959,
            "upload_time": "2023-03-14T15:21:57",
            "upload_time_iso_8601": "2023-03-14T15:21:57.407595Z",
            "url": "https://files.pythonhosted.org/packages/05/d8/6ebd1a1a28aa70fa9650cc34559cf97ea2d888d109ed2cb56d53e612f315/m360_middleware-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d74bafd38739db51fe4d8e9cc77dde1d064eddaf03ab91f71795043d5ab7744e",
                "md5": "2381010bd66ea8f38f3fd5f363e4d714",
                "sha256": "64f8904ad6d8df6d0fd82956a8de009fabce788602bf1e97206549a2a35b9683"
            },
            "downloads": -1,
            "filename": "m360-middleware-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "2381010bd66ea8f38f3fd5f363e4d714",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 36480,
            "upload_time": "2023-03-14T15:21:59",
            "upload_time_iso_8601": "2023-03-14T15:21:59.076508Z",
            "url": "https://files.pythonhosted.org/packages/d7/4b/afd38739db51fe4d8e9cc77dde1d064eddaf03ab91f71795043d5ab7744e/m360-middleware-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-14 15:21:59",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "m360-middleware"
}
        
Elapsed time: 0.04413s