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
Close
Hashes for services_communicator-0.2.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfd38de1ee080252efc49e386224b69275ea926629927155a661a4bd7d58b7ec |
|
MD5 | fe5ced2bed54f13830c8696eef895cd3 |
|
BLAKE2b-256 | 4586e771eaaed4ceb9224d82d0af49ade50e8d8035b6c7a936b0a762af060310 |
Close
Hashes for services_communicator-0.2.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 052eee6a0eb091aab42bbde29b4ba8c74935ec87db6eef28b8e4e4ba0a098fc6 |
|
MD5 | 6d2052eb19f1355e50adf7ed40198397 |
|
BLAKE2b-256 | afcf0b2ee6e31df58bcc6417e1f6da76e037ebd936ab413ae0801bfbbb2e7952 |