Communicator for internal services
Project description
Communicator for internal services
Documentation
The full documentation is at https://services_communicator.readthedocs.io.
Quickstart
Install Services-Communicator:
pip install services_communicator
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'services_communicator.apps.services_communicator',
...
)
Make migrate to database:
python manage.py migrate
Add CREDENTIALS on settings.py file:
CREDENTIALS = { <service id>: {"username": <username>, "password": <password>}, <service id>: {"username": <username>, "password": <password>}, .......................................................... } or, CREDENTIALS = { "<service slug>": {"username": <username>, "password": <password>}, "<service slug>": {"username": <username>, "password": <password>}, .......................................................... } or, CREDENTIALS = { "<service guid>": {"username": <username>, "password": <password>}, "<service guid>": {"username": <username>, "password": <password>}, .......................................................... }
Now make your own Communicator:
from services_communicator.communicator import Communicator
class CustomCommunicator(Communicator):
""" Create your custom method here like this by inheriting Communicator"""
def get_roles(self, *args, **kwargs):
"""
- To get other service roles
:return:
"""
path = self.service.get_full_url + "/users/get_role/" # service url extension to do this task
response = self._get_action(path=path, headers=self._token())
return response.json()
def post_roles(self, *args, **kwargs):
"""
- To create other service roles
:return:
"""
data = data
path = self.service.get_full_url + "/users/create_role/" # service url extension to do this task
response = self._post_action(path=path, data=data, headers=self._token())
return response.json()
def patch_roles(self, *args, **kwargs):
"""
- To create other service roles
:return:
"""
data = data
path = self.service.get_full_url + "/users/update_role/" # service url extension to do this task
response = self._patch_action(path=path, data=data, headers=self._token())
return response.json()
To perform action, initialize your CustomCommunicator and call your required methods:
service_communicator = CustomCommunicator(**{"service_id": <id>})
or,
service_communicator = CustomCommunicator(**{"service_slug": "<service slug>"})
or,
service_communicator = CustomCommunicator(**{"service_guid": "<service guid>"})
Now you can call your methods to perform specific task:
response = service_communicator.get_roles()
Precaution
This module is designed only for the personal development purpose.
History
0.1.0 (2020-01-13)
First release on PyPI.
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
Built Distribution
File details
Details for the file services_communicator-0.3.0.tar.gz
.
File metadata
- Download URL: services_communicator-0.3.0.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c727d861427d3d96dd51927beae7d5a4fcf7e990415ee1ef9b26a90994e8d15 |
|
MD5 | 15be56cd34f65ead40dc457c8dc8d910 |
|
BLAKE2b-256 | 0761c45c85c8e9cd9c454d6c7a5cc7c8d8a3350f78d0e4572871c8d4f32180fb |
File details
Details for the file services_communicator-0.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: services_communicator-0.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ab47f432653834b4b70bb4cd6d18da4cbd1fd9056dc8c5bf476afda978c4cfc |
|
MD5 | 46692f17a0fa1df48eeb1f5120ec04fe |
|
BLAKE2b-256 | 0a83d0c6c3692a10159fae9e3573533e13d57d786671750c2060ed0ce6dbe831 |