Services-Communicator
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.
Metadata
Release files for services-communicator 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| services_communicator-0.3.0.tar.gz | 9.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| services_communicator-0.3.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 20.1 kB
Release files / services_communicator-0.3.0.tar.gz
| Download URL | services_communicator-0.3.0.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c727d861427d3d96dd51927beae7d5a4fcf7e990415ee1ef9b26a90994e8d15
|
|
BLAKE2b-256 checksum How to use checksums |
0761c45c85c8e9cd9c454d6c7a5cc7c8d8a3350f78d0e4572871c8d4f32180fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / services_communicator-0.3.0-py2.py3-none-any.whl
| Download URL | services_communicator-0.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
1ab47f432653834b4b70bb4cd6d18da4cbd1fd9056dc8c5bf476afda978c4cfc
|
|
BLAKE2b-256 checksum How to use checksums |
0a83d0c6c3692a10159fae9e3573533e13d57d786671750c2060ed0ce6dbe831
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|