Skip to main content

Communicator for internal services

Project description

https://badge.fury.io/py/services_communicator.svg https://travis-ci.org/eshafik/services_communicator.svg?branch=master https://codecov.io/gh/eshafik/services_communicator/branch/master/graph/badge.svg

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


Download files

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

Source Distribution

services_communicator-0.2.2.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

services_communicator-0.2.2-py2.py3-none-any.whl (10.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file services_communicator-0.2.2.tar.gz.

File metadata

  • Download URL: services_communicator-0.2.2.tar.gz
  • Upload date:
  • Size: 9.4 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

Hashes for services_communicator-0.2.2.tar.gz
Algorithm Hash digest
SHA256 94eb60e7c13fe11df47b573e537ad96fba49e0a51edd33cda62b938668d3232a
MD5 4bd6a6f9bd46cdeffa5f2e5e839e7522
BLAKE2b-256 f0d02ae8edf46495e1d66fc080b53c28c3549eae821baf6c91f30788148e6fcb

See more details on using hashes here.

File details

Details for the file services_communicator-0.2.2-py2.py3-none-any.whl.

File metadata

  • Download URL: services_communicator-0.2.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.1 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

Hashes for services_communicator-0.2.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 713715ecf174162524331d53d0b6c7c4f350a2934ecb67c18c6168939c90e9a2
MD5 da19da21be4deaa50d5e1f4bedf9a30d
BLAKE2b-256 d7b2f163463ddd9e6352b958fd8da14a8db9dec1fcb3f3247b00038f3f967794

See more details on using hashes here.

Supported by

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