Skip to main content

Клиент для взаимодействия с Загрузчиком данных в витрину

Project description

Клиент для взаимодействия с РВД посредством Адаптера

Подключение

settings:

INSTALLED_APPS = [
    'uploader_client',
]

apps:

from django.apps import AppConfig as AppConfigBase

class AppConfig(AppConfigBase):

    name = __package__

    def __setup_uploader_client(self):
        import uploader_client

        uploader_client.set_config(
            uploader_client.configuration.Config(
                agent_url='http://localhost:8090',
                system_mnemonics='MNSV03',
                timeout=1,
                request_retries=1,
            )
        )

    def ready(self):
        super().ready()
        self.__setup_uploader_client()

Использование Proxy API для отправки запросов в РВД

Заменить используемый интерфейс на ProxyAPIInterface и добавить необходимые параметры в конфигурации:

uploader_client.set_config(
    ...,
    RegionalDataMartUploaderConfig(
        interface='uploader_client.contrib.rdm.interfaces.rest.ProxyAPIInterface',
        cache=<cache>,
        url=<url>,
        datamart_name=<datamart_name>,
        organization_ogrn=<organization_ogrn>,
        installation_name=<installation_name>,
        installation_id=<installation_id>,
        username=<username>,
        password=<username>,
    )
)

где

  • cache - кеш django для хранения токена доступа (например, caches[DEFAULT_CACHE_ALIAS]);
  • url - URL до хоста Datamart Studio;
  • datamart_name - мнемоника Витрины;
  • organization_ogrn - ОГРН организации, в рамках которой развёрнута Витрина;
  • installation_name - имя инсталляции в целевой Витрине;
  • installation_id - идентификатор инсталляции;
  • username - имя пользователя IAM;
  • password - пароль пользователя IAM.

Эмуляция

Заменить используемый интерфейс на эмулирующий запросы:

uploader_client.set_config(
    ...,
    uploader_client.configuration.Config(
        interface=(
            'uploader_client.contrib.rdm.interfaces.rest'
            '.OpenAPIInterfaceEmulation'
        )
    )
)

Запуск тестов

$ tox

API

Передача сообщения

from uploader_client.adapters import adapter
from uploader_client.interfaces import OpenAPIRequest

class Request(OpenAPIRequest):

    def get_url(self):
        return 'http://localhost:8090/MNSV03/myedu/api/edu-upload/v1/multipart/csv'

    def get_method(self):
        return 'post'

    def get_files(self) -> List[str]:
        return [
            Path('files/myedu_schools.csv').as_posix()
        ]

result = adapter.send(Request())

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

uploader_client-0.4.3.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uploader_client-0.4.3-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file uploader_client-0.4.3.tar.gz.

File metadata

  • Download URL: uploader_client-0.4.3.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for uploader_client-0.4.3.tar.gz
Algorithm Hash digest
SHA256 3a039c81e02deecb6a06075c75fe1b959b63f298a3f6860fc194536b1ed47670
MD5 af10c8befc4b0a4c4075ce2ee81b9f58
BLAKE2b-256 be966208e6c60f7bba7ab6da654ab00b71049e90e792aaa4a18f2d79ecd1b22a

See more details on using hashes here.

File details

Details for the file uploader_client-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for uploader_client-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9b2f8292c02a856054aaf046217d7c4566c63dce33fb82d7e8eca8ca068b7a64
MD5 719739b33039de09235728409af8ce4a
BLAKE2b-256 8405e445c7d96b3f69cb35a3325c18b4d673c9386465bcdaf13f129d3a652acb

See more details on using hashes here.

Supported by

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